|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 22 Jul 2015 10:59 PM |
| So, what you said, and should I make User a StringValue instead of an ObjectValue? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 22 Jul 2015 11:07 PM |
| So... Is there something wrong still? Or... No? I'm confused. q.q |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 22 Jul 2015 11:23 PM |
| Sorry. Most people don't usually post the working product in the forum. :P |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|