This script is inside a part. And when you touch without a ForceField you lose 100 health. (There is a shop where you can buy more health. That's why you lose 100 health instead of just setting health to 0) And if you touch it with a ForceField, you're supposed to not lose any health and have a 25% chance of getting 100 points.
debounce = false
script.Parent.Touched:connect(function(hit)
if not hit then
return true
elseif not hit.Parent then
return true
end
local h = hit.Parent:findFirstChild("Humanoid")
local ff = hit.Parent:FindFirstChild("ForceField1"),hit.Parent:FindFirstChild("ForceField2"),hit.Parent:FindFirstChild("ForceField3"),hit.Parent:FindFirstChild("ForceField4")
local nff1 = hit.Parent:FindFirstChild("ForceField1",false)
local nff2 = hit.Parent:FindFirstChild("ForceField2",false)
local nff3 = hit.Parent:FindFirstChild("ForceField3",false)
local nff4 = hit.Parent:FindFirstChild("ForceField4",false)
local p = hit.Parent:findFirstChild("Grass"),hit.Parent:findFirstChild("Rock")
if h then
if ff then
print (hit.Parent)--Player
local points = game.Players:GetPlayerFromCharacter(hit.Parent):WaitForChild("Points")
if hit.Parent.RocksLeft.Value ~= 0 then
hit.Parent:WaitForChild("RocksLeft").Value = hit.Parent.RocksLeft.Value - 1
else
ff:Destroy()
end
local var1 = 1
local var2 = math.random(1,4)
if var2 == var1 then
points.Value = points.Value + 100
end
script.Parent:Destroy()
elseif nff1 or nff2 or nff3 or nff4 then
if debounce == false then
debounce = true
h.Health = h.Health - 100
print 'rip'
script.Parent:Destroy()
end
wait(.5)
debounce = false
end
elseif p then
local var = math.random(1,3)
if var == 1 then
script.Parent:Destroy()
end
end
end)
The problem is that when you touch it with a ForceField you loose 100 health, and when you touch it without a ForceField you don't lose any health.
