Ad
Log in to vote
0

Why does this script when a player sits on a certain seat is not working?

Asked by 3 months ago
Edited 3 months ago

I'm trying to make is a script that will give the player a tool when you sit on a certain seat. Then, when the player jumps off the seat, the tool should be gone from their backpack.

The code below is what I'm using and I cannot get it to work.

function onChildAdded(child)
if child.Name == "SeatWeld" then
if child.Part1.Name == "Torso" then
player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
if player ~= nil then
tool = game.ReplicatedStorage.MachineShoulder:Clone() 
                tool.Parent = player.Backpack
            end
        end
    end
end

function onChildRemoved()
if tool ~= nil then
        tool:Remove()
    end
end

script.Parent.ChildAdded:connect(onChildAdded)
script.Parent.ChildRemoved:connect(onChildRemoved)


Can anyone explain to me why is this not working?

Thank you.

EDIT: I am getting no sort of error when sitting on a seat. Just some extra information for you.

Answer this question