In ServerStorage, I have a tool (it’s a sunscreen bottle) and inside I have a local script.
Script:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
local tool = script.Parent
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://7238904032"
local loaded = Animator:LoadAnimation(animation)
tool.Activated:Connect(function(mouse)
mouse.Button1Down:Connect(function()
loaded:Play()
end)
end)
Please, next time inform us about errors in the Output.
Tool.Activated does not send any arguments, and it is fired when the player clicks with the mouse (without Ctrl being pressed), so there is no need to listen when the mouse presses inside the function.
Your code should look like this:
local player = game.Players.LocalPlayer
local character = script.Parent.Parent
local Animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
local tool = script.Parent
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://7238904032"
local loaded = Animator:LoadAnimation(animation)
tool.Activated:Connect(function()
loaded:Play()
end)
Also I forgot to mention so this is in server storage at first but then if the player purchases the sunscreen with a GUI it puts it in their backpack which is why it says its in the backpack now
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
local tool = script.Parent
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://7238904032"
local loaded = Animator:LoadAnimation(animation)
tool.Activated:Connect(function()
loaded:Play()
end)
yea I made the animation im not sure how well I did it but it should be working bc if I test it on a dummy it plays the animation although I am new to animations as this is my first time working with them