0

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

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