Scripting~(broken code) How do i play animation after mouse clisk

Hi <3 I haven’t skill in scripting but , i used AI for create script. It isn’t work.
Pls fix this code or send tutorial.

I put it in
image

Script :

local animationId = “13660732928”

local function playAnimation()
local humanoid = script.Parent:FindFirstChildOfClass(“Humanoid”)
if humanoid then
humanoid:LoadAnimation(Instance.new(“Animation”, humanoid)).AnimationId = animationId
end
end

script.Parent.MouseButton1Click:Connect(playAnimation)

1 Like

da fuq kinda script is that u should put that in a tool, and disable requireshandle

How to do it :sweat_smile:
Just I don’t know

:skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull: :skull:

anyway add a tool inside starter tools. and in the propreties of the tool you can find requires handle, disable it.

Wait, it isn’t tool… Its just: animation after click without tool

then tell ur dumbass chatgpt to use player:GetMouse and replace the old code with what it gives you

local animationId = “13660673130”
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local function playAnimation()
local humanoid = player.Character and player.Character:FindFirstChildOfClass(“Humanoid”)
if humanoid then
humanoid:LoadAnimation(Instance.new(“Animation”, humanoid)).AnimationId = animationId
end
end

mouse.Button1Down:Connect(playAnimation)

Its new but it doesn’t work

local animationId = “13660673130”
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local function playAnimation()
local humanoid = player.Character and player.Character:FindFirstChildOfClass(“Humanoid”)
if humanoid then
local track = humanoid:LoadAnimation(Instance.new(“Animation”, humanoid))
track.AnimationId = animationId
track:Play()
end
end

mouse.Button1Down:Connect(playAnimation)

reedited the code copy and paste now

--[[
    This script will play an animation when mousebutton1 is clicked.
]]

--[[ SERVICES ]]
local Players = game:GetService("Players")

--[[ CONSTANTS ]]
local ANIMATION_ID = "rbxassetid://13660732928" --put your animation here

--[[ VARIABLES ]]
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local mouse = player:GetMouse()

local animation = Instance.new("Animation")
animation.AnimationId = ANIMATION_ID
local animationTrack = animator:LoadAnimation(animation)

--[[ CODE ]]
mouse.Button1Down:Connect(function()
    animationTrack:Play()
end)
3 Likes

THAAAANK YOU IT WORKING <33333

You should try out ChatGPT! It might be able to solve these kind of issues.

1 Like

Nah man…no XD
dsfksidfsopdf
ssfdsdfsdf (30 words)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.