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

What is Wrong with my Claim Door Script?

Asked by
IcyEvil 260 Moderation Voter
9 years ago

Im trying to make it to where, It inserts Players name into the 'local owner' who touch the part 'Invisi' But it isnt working no Idea why...

Here is the script.

function onClicked (playerWhoClicked)
    local owner = { }
for _,v in pairs(game.Workspace.floor:GetChildren()) do
v["Claim Dorm"].Invisi.Touched:connect(function(hit)
    for _,l in pairs(game.Players:GetChildren())do
        if hit.Parent then
            local humanoid = l.Character:findFirstChild("Humanoid")
            if humanoid then
                script.Parent.Parent.Name = l.Name.."'s Dorm"
                table.insert(l.Name, #owner)
            end
            end
    end
    script.Parent.CanCollide = false
    script.Parent.Parent["Smooth Block Model"].CanCollide = false
    wait(5)
    script.Parent.CanCollide = true
    script.Parent.Parent["Smooth Block Model"].CanCollide = true
end)
end


end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
You have a "hit.Parent" condition when hit is never defined. You have a Click function while you're checking for someone who touched the door. Fix the hit.Parent. I'm not sure what a ClickDetector click function returns, but use whatever that is to check the player's name. SlickPwner 534 — 9y
0
No, the 'hit.Parent' is inside a Touched event. Perci1 4988 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

The Touched event is inside the onClick function. So, the Touched event can only fire when ClickDetector is fired at the same time. Try making a different script that does what you need it to do, and insert it into all the doors. That's the only thing I can recommend right now, I can't test with Studio at this second.

Ad

Answer this question