This script is inside a rock, and when you touch it without a ForceField, it's supposed to take 100 damage away. When you touch it and you DO have a ForceField, it's supposed to destroy it's self and have a 25% chance of giving you 100 points. If the rock doesn't touch a person, but it touches grass or a different rock, it's supposed to have a 33% chance of staying on the ground.
debounce = false
script.Parent.Touched:connect(function(hit)
if not hit then
print 'gg roblox'
return true
elseif not hit.Parent then
print 'gg roblox'
return true
end
local h = hit.Parent:FindFirstChild("Humanoid")
local ff = hit.Parent:FindFirstChild("ForceField")
local p = hit.Parent:FindFirstChild("Grass")
local p2 = hit.Parent:findFirstChild("Rock")
local rl = hit.Parent:FindFirstChild("RocksLeft")
if h then
print 'humanoid found'
if ff then
print 'ff found'
print (hit.Parent)--Player
local points = game.Players:GetPlayerFromCharacter(hit.Parent):WaitForChild("Points")
if rl.Value ~= 1 then
rl.Value = rl.Value - 1
else
rl.Value = 0
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()
else
if debounce == false then
debounce = true
h.Health = h.Health - 100
print 'rip'
script.Parent:Destroy()
end
wait(.5)
debounce = false
end
elseif p or p2 then
local var = math.random(1,3)
if var == 1 then
script.Parent:Destroy()
end
end
end)
The problem is that when you do touch it with a ForceField, it says:
attempt to index local 'rl' (a nil value)
Even though I'm asking for a IntValue named "RocksLeft"
Another thing is, when the rock hits the ground it doesn't destroy. None of them do. Even though there are a lot spawning each second
while true do
wait(.05)
clone = game.ServerStorage.GameRock:Clone()
clone.Parent = workspace
clone.Position = Vector3.new(math.random(-255,255),math.random(150,200),math.random(-255,255))
end

5 comments
Im pretty sure it is because it is waiting for a child that is already there, just a guess
I tried without it but it said that "RocksLeft is not a valid member of model"
Post the code you're currently using, please.
@Perci1 There
Read it now