I'm practicing but not sure how to make a value decrease like say I try to make a brick that makes your health -20 on hit, but not 20 health, just subtracts 20 from your current health. How do I do that? And I assume it would be the same for reflectance or something like that too.
script.Parent.Touched:connect(function(hit) print(hit) hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health -20 --Doesn't work end)
thanks
local debounce = false script.Parent.Touched:connect(function(obj) if debounce == true then return end --To make it not run all at once when you hit it debounce = true if obj.Parent:FindFirstChild("Humanoid") then local human = obj.Parent.Humanoid human.Health = human.Health - 20 end wait(.2) debounce = false end)
game.Workspace.Part.Touched:connect(function(hit) --Rename "Part" with whatever the name is of the brick you want touched. print(hit) hit.Parent.Humanoid.Health = 0 end)
This should work.