I made a thing where if the player is holding an empty basket and interacts with the proximity prompt of said model it will destroy the empty basket in their hand and replace it with a full one. This works seamlessly so far, except when I equip the full basket, it’s still playing the animation of the empty one. What’s causing this?
local emptyToolName = "LaundryBasketEmpty"
local fullToolName = "LaundryBasketFull"
local proximityPrompt = script.Parent
local function onPromptTriggered(player)
local character = player.Character
local backpack = player:FindFirstChild("Backpack")
local emptyTool = character:FindFirstChild(emptyToolName) or backpack:FindFirstChild(emptyToolName)
if emptyTool then
emptyTool:Destroy()
local fullTool = game.ServerStorage:FindFirstChild(fullToolName):Clone()
fullTool.Parent = character
end
end
proximityPrompt.Triggered:Connect(onPromptTriggered)
Holding Empty Basket tool
Interact with Proximity Prompt + Receive Full Basket Tool
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local holdingbasketAnimation = script:WaitForChild("holdingbasket")
local holdingbasket = animator:LoadAnimation(holdingbasketAnimation)
holdingbasket.Priority = Enum.AnimationPriority.Action
holdingbasket.Looped = true
local tool = script.Parent
tool.Equipped:Connect(function()
holdingbasket:Play()
end)
tool.Unequipped:Connect(function()
holdingbasket:Stop()
end)
Basket Full (given after interacting with prompt)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local holdingbasketAnimation = script:WaitForChild("holdingbasket")
local holdingbasket = animator:LoadAnimation(holdingbasketAnimation)
holdingbasket.Priority = Enum.AnimationPriority.Action
holdingbasket.Looped = true
local tool = script.Parent
tool.Equipped:Connect(function()
holdingbasket:Play()
end)
tool.Unequipped:Connect(function()
holdingbasket:Stop()
end)
I think it still plays the animation from the empty basket script. it doesn’t activate the Unequipped function because it gets deleted so it runs forever
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local holdingbasketAnimation = script:WaitForChild("holdingbasket")
local holdingbasket = animator:LoadAnimation(holdingbasketAnimation)
holdingbasket.Priority = Enum.AnimationPriority.Action
holdingbasket.Looped = true
local tool = script.Parent
tool.Equipped:Connect(function()
holdingbasket:Play()
end)
tool.Destroying:Connect(function()
holdingbasket:Stop()
end)
tool.Unequipped:Connect(function()
holdingbasket:Stop()
end)
I added it to the script, but it sadly didn’t fix the issue:
I also discovered that if I have the empty basket in my backpack and use the prompt without holding the basket, it gives me the full basket as expected. Then, when I unequip the full basket, the holding animation stops.
But when I’m holding the empty and use the prompt the animation continues playing even when I unequip
if emptyTool then
character:WaitForChild("Humanoid"):UnequipTools()
emptyTool:Destroy()
local fullTool = game.ServerStorage:FindFirstChild(fullToolName):Clone()
fullTool.Parent = character
end
end
I think it isn’t working because both scripts Loads the animation separately. Try this instead of .Destroying because i dont think roblox has fullly implemented that one yet.
tool:GetPropertyChangedSignal("Parent"):Connect(function()
if not tool.Parent then
holdingbasket:Stop()
end
end)