generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Why does this affect me?

Previous Thread :: Next Thread 
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
22 Jul 2015 10:41 PM
enabled = true

function onTouch(part)
if part.Parent.Name ~= script.Parent.User.Value and enabled == true then
enabled = false
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then
humanoid.Health = humanoid.Health -4
wait(1)
enabled = true
end
end
end
script.Parent.Touched:connect(onTouch)



script.Parent.User is an ObjectValue that refers to my Player instance. Obviously has the same name as the part.Parent, which would be my character in the workspace. What I want this to do is damage anything it hits that isn't me. Help on why this will work on me is appreciated... Thanks! =)
Report Abuse
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
22 Jul 2015 10:45 PM
redo of script: ( still broken though )


function onTouch(part)
if part.Parent:FindFirstChild("Humanoid") then
if part.Parent.Name ~= script.Parent.User.Value and enabled == true then
enabled = false
part.Parent.Humanoid.Health = part.Parent.Humanoid.Health -4
wait(1)
enabled = true
end
end
end
script.Parent.Touched:connect(onTouch)
Report Abuse
Rocketerkid is not online. Rocketerkid
Joined: 10 Oct 2011
Total Posts: 1237
22 Jul 2015 10:53 PM
Instances are not the same as string, and ObjectValues lock on to Instances. So. Try this.

function onTouch(part)
if part.Parent:FindFirstChild("Humanoid") then
if part.Parent.Name ~= script.Parent.User.Value.Name and enabled == true then
enabled = false
part.Parent.Humanoid.Health = part.Parent.Humanoid.Health -4
wait(1)
enabled = true
end
end
end
script.Parent.Touched:connect(onTouch)

Report Abuse
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
22 Jul 2015 10:59 PM
So, what you said, and should I make User a StringValue instead of an ObjectValue?
Report Abuse
Rocketerkid is not online. Rocketerkid
Joined: 10 Oct 2011
Total Posts: 1237
22 Jul 2015 11:02 PM
function onTouch(part)
if part.Parent:FindFirstChild("Humanoid") then
if part.Parent.Name ~= script.Parent.User.Value and enabled == true then
enabled = false
part.Parent.Humanoid.Health = part.Parent.Humanoid.Health -4
wait(1)
enabled = true
end
end
end
script.Parent.Touched:connect(onTouch)


Assuming that the Part's parent is the player, and the object's value is the player. Then the script I just sent should work at least in that conditional.
Report Abuse
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
22 Jul 2015 11:05 PM
Alright, I've devised something that works going off of some of your information. For the future reference of anyone else, I'll post it here. (User is now a StringValue whos value is the name of the LocalPlayer.)

enabled = true
Attacker = game.Players:FindFirstChild(script.Parent.User.Value)

function onTouch(part)
if part.Parent:FindFirstChild("Humanoid") then
if part.Parent.Name ~= script.Parent.User.Value and enabled == true then
if Attacker then
enabled = false
part.Parent.Humanoid.Health = part.Parent.Humanoid.Health - (10 + Attacker.leaderstat.DevilFruit.Value/4)
wait(1)
enabled = true
end
end
end
end
script.Parent.Touched:connect(onTouch)
Report Abuse
Rocketerkid is not online. Rocketerkid
Joined: 10 Oct 2011
Total Posts: 1237
22 Jul 2015 11:07 PM
So... Is there something wrong still? Or... No? I'm confused. q.q
Report Abuse
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
22 Jul 2015 11:19 PM
"Alright, I've devised something that works going"

Alright, I've devised something **that works** going

*that works*
Report Abuse
Rocketerkid is not online. Rocketerkid
Joined: 10 Oct 2011
Total Posts: 1237
22 Jul 2015 11:23 PM
Sorry. Most people don't usually post the working product in the forum. :P
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
22 Jul 2015 11:28 PM
In other words, "Thank you, Rocketerkid! You answered my question precisely, and I'm very grateful and better educated as a result of the time you took to post your response. If there's anything I can do to repay you, just let me know.".
Report Abuse
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
22 Jul 2015 11:30 PM
Actually, no. It was all my work. All he corrected me on was to change the ObjectValue to a StringValue. Still, I would've never figured that out on my own. Thank you for your help.
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
22 Jul 2015 11:50 PM
... wow... The hubris...

Like the beggar who says "That's all?", after you give him five bucks...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image