I need a tool for my game that stays on players backs while in their inventory and not in use. Currently, I am using a baguette as a model. I have created it to spin because my game will be very silly. But due to me not being great at scripting with models, the models disappear when one player holds it. And I have not been able to fix this issue. I assume it is because the script gets all the baguettes, but I still haven’t found a simple fix.
Here is a GIF of what I am talking about.
https://gyazo.com/f72ddd0a914f2b8559c5eaad1221608d
I have tried multiple things. I could not weld when unequipped due to my tool needing to be on a hinge.
This is my script so far.
wait(2)
local p = script.Parent
local bag = game.ReplicatedStorage.bag:Clone()
bag.Parent = p
wait(.2)
script.Parent.bag.Attachment1.Parent = p.Torso
script.Parent.bag.NoCollisionConstaint.Part0 = p.bag
local block = game.ReplicatedStorage.blocker:Clone()
block.Parent = p
script.Parent.blocker.Position = p.Torso.Position
script.Parent.blocker.WeldConstraint.Part0 = p.blocker
script.Parent.blocker.WeldConstraint.Part1 = p.Torso
script.Parent.bag.NoCollisionConstaint.Part1 = p.blocker
game.ReplicatedStorage.grip.OnServerEvent:Connect(function(player)
script.Parent.bag.Transparency = 1
end)
game.ReplicatedStorage.gripoff.OnServerEvent:Connect(function(player)
script.Parent.bag.Transparency = 0
end)
in the tool
local holdanimationid = 6764886151
local swinganimationid = 6764901384
repeat wait() until game.Players.LocalPlayer.Character
local lp = game.Players.LocalPlayer
local sp = script.Parent
local debounce = true
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://" .. holdanimationid
local holdtrack = lp.Character.Humanoid:LoadAnimation(anim)
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://" .. swinganimationid
local swingtrack = lp.Character.Humanoid:LoadAnimation(anim)
sp.Equipped:connect(function()
game.ReplicatedStorage.grip:FireServer()
holdtrack:Play()
end)
sp.Unequipped:connect(function()
holdtrack:Stop()
game.ReplicatedStorage.gripoff:FireServer()
end)
sp.Activated:connect(function()
if debounce == true then
debounce = false
swingtrack:Play()
wait(swingtrack.Length)
debounce = true
end
end)