I want to create a door so that when a player walks tries to walk through it, it will find a leaderstat (Points) of the player and if it is over the amount (20) let them through otherwise it won't. Here is the script so far:
function onTouched(hit)
if ting == 0 then
ting = 1
check = hit.Parent:FindFirstChild("Humanoid")
script.Parent.CanCollide=true
if check ~= nil then
if hit.Parent.Name == owner.Value then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local Points = stats:findFirstChild("Points")
if Points.Value > (0) then
script.Parent.CanCollide=false
wait(0.5)
script.Parent.CanCollide=true
end
end
end
end
end
Thanks,
CallKnuss

5 comments
From what I'm seeing, 'ting' is a nil value, as it isn't used outside the code, i.e. the variable is there b4 the function, + you have no event to fire & let the function be aware if the player is walking through the 'door.'
What is the variable "ting"? Also, you might also want to make the door uncollided client side (so other people can't sneak in) via remoteevents/remotefunctions.
So what do I need to fix?
"if Points.Value > 0 then"
Ok