I have a grenade on the map that’s anchored. But I can get it to unanchor after the player picks it up.
local tool = script.Parent
local plr = game:GetService("Players").LocalPlayer
local anim = Instance.new("Animation")
local sound1 = tool:WaitForChild("PinPull2")
local sound2 = tool:WaitForChild("PinPull4")
local sound = {sound1, sound2}
anim.AnimationId = 'https://www.roblox.com/Assest?ID=13771756559'
local track
local db = false
tool.Activated:Connect(function()
tool.Handle.Anchored = false
if db == false then
db = true
game.ReplicatedStorage.activate:FireServer(plr:GetMouse().Hit,tool)
task.wait(10)
db = false
end
end)
tool.Equipped:Connect(function()
sound[math.random(1, #sound)]:Play()
track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
track.Priority = Enum.AnimationPriority.Action
track:Play()
end)
tool.Unequipped:Connect(function()
if track then
track:Stop()
sound[math.random(1, #sound)]:Stop()
end
end)
local tool = script.Parent
local plr = game:GetService("Players").LocalPlayer
local anim = Instance.new("Animation")
local sound1 = tool:WaitForChild("PinPull2")
local sound2 = tool:WaitForChild("PinPull4")
local sound = {sound1, sound2}
anim.AnimationId = 'https://www.roblox.com/Assest?ID=13771756559'
local track
local db = false
local originParent=tool.Parent
repeat
wait()
until tool.Parent~=originParent
tool.Handle.Anchored=false
tool.Activated:Connect(function()
if db == false then
db = true
game.ReplicatedStorage.activate:FireServer(plr:GetMouse().Hit,tool)
task.wait(10)
db = false
end
end)
tool.Equipped:Connect(function()
sound[math.random(1, #sound)]:Play()
track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
track.Priority = Enum.AnimationPriority.Action
track:Play()
end)
tool.Unequipped:Connect(function()
if track then
track:Stop()
sound[math.random(1, #sound)]:Stop()
end
end)
The parent shall be the tool and i forgot to tell you to set the tool variable to script.parent
so just add this at the top
local tool = script.Parent
the red line under the tool indicates that its an error
1 more tip:
Anything done on the client wont be visible on the server
I looked at youre code agian and it seems that you play audio in the client script that means only the player who uses it will hear the “PinPull2” or “PinPull4” sound effects
I think you should look into the diffrance between client and server scripting.