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

Player only wall won't work, It keeps forcing players to not enter, why the hell Is that?

Asked by 2 years ago

This is just dumb, I made a wall that won't let NPCS go through but only players does but It keeps working players to not enter! Its just dumb!

Script:

script.Parent.Touched:Connect(function(Hit)
    local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)

    if Player then
        script.Parent.CanCollide = false
    else
        script.Parent.CanCollide = true
    end
end)

1 answer

Log in to vote
0
Answered by 2 years ago

try changing your script to this

script.Parent.Touched:Connect(function(Hit)
    local Player = game.Players:FindFirstChild(Hit.Parent.Name)

    if Player then
        script.Parent.CanCollide = false
    else
        script.Parent.CanCollide = true
    end
end)

maybe this will work

Ad

Answer this question