I want to make a tool that will anchor a player upon being equipped and unanchor the player when the tool is unequipped. I have tried just doing things like Handle.anchored = true but they don’t work how I want them to.
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character
local AnchorPoint = player:FindFirstChild("Torso")
if tool.Equipped then
AnchorPoint.Anchored = true
elseif tool.Unequipped then
AnchorPoint.Anchored = false
else AnchorPoint.Anchored = false
end
You could try doing something like this instead, connecting the tool.Equipped and tool.Unequipped events to a function:
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character
local AnchorPoint = player:FindFirstChild("Torso")
tool.Equipped:Connect(function()
AnchorPoint.Anchored = true
end)
tool.Unequipped:Connect(function()
AnchorPoint.Anchored = false
end)
Let me know if this doesn’t work, I’m away from my computer and I couldn’t test the code.
local tool = script.Parent
local character
local AnchorPoint
tool.Equipped:Connect(function()
character = tool.Parent
AnchorPoint = character.HumanoidRootPart
AnchorPoint.Anchored = true
end)
tool.Unequipped:Connect(function()
AnchorPoint.Anchored = false
end)