Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone tell me how I can make this script function properly?

Asked by 8 years ago
Edited 8 years ago

script {function touch(hit) hit.humanoid.Health = godsfinalresonance.Health - 20 end script.Parent.Touched:connect(touch) godsfinalresonance = game.workspace.Players.godsfinalresonance}

I tried putting my tag (godsfinalresonance = game.workspace.Players.godsfinalresonance) at the top but it told me line 1 had an error so I placed it at the bottom but now line 2 has an error. I'm trying to make it so when I step on the brick my health is reduced. I'm still a beginner so I would appreciate some assistance if possible.

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago
  1. Humanoid needs to be capitalized for it to work.
  2. I recommend you do a check for humanoid like "if hit.Parent:FindFirstChild("Humanoid") then"
  3. If godsfinalresonance's health stays the same, then your health will never go below 80.
  4. (which i hope u already know) It will not work unless godsfinalresonance is a person or thing inside of the "Players" section with a health value, so at like 1 keep "local godsfinalresonance = game.Players.godsfinalresonance" and you need a person with that name.

I hope I helped if not, please message me or comment on my answer!

0
I changed my script to try to make it function here's the script {local godsfinalresonance = game.workspace.Players.godsfinalresonance if hit.parent:FindFirstChild("Humanoid") then function touch(hit) hit.Humanoid.Health = godsfinalresonance.Health - 20 end script.Parent.Touched:connect(touch)} the error is Workspace.Part.Script:7: 'end' expected (to close 'if' at line 2) near '<eof>' SacredEden 10 — 8y
0
You'd need it like this.. local godsfinalresonance = game.Players.godsfinalresonance script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid.Health = godsfinalresonance.Health - 20 end end)                                                                      RockerCaleb1234 282 — 8y
Ad

Answer this question