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

How to create a leaderstats door?

Asked by 7 years ago

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

0
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.' TheeDeathCaster 2368 — 7y
0
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. User#14829 0 — 7y
0
So what do I need to fix? CallKnuss 5 — 7y
0
"if Points.Value > 0 then" Experiencehghj23 0 — 7y
0
Ok CallKnuss 5 — 7y

Answer this question