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

How do I make a function work when a tool is UnEquipped?

Asked by 9 years ago

I tried this script:

tool = script.Parent.Parent
player = game.Players.LocalPlayer
pm = player:GetMouse()

tool.Equipped:connect(function(mouse)
    game.ReplicatedStorage.Kill:Clone().Parent = player.PlayerGui
end)

tool.UnEquipped:connect(function(mouse)
    player.PlayerGui.Kill:Destroy()
end)

1 answer

Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

Careful; capitalization error. Remember that programming languages are case-sensitive. This is due to the fact that it was made to be as compact as possible, leaving less room for redundancy.

Unequipped Event

tool.Unequipped:connect(function ()
    player.PlayerGui.Kill:Destroy()
end)
Ad

Answer this question