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?
EDIT: I am getting no sort of error when sitting on a seat. Just some extra information for you.