Hello, anybody know why this script may not work? (animation script)

Hello,
I’ve made a script for a simple action however it seems to not work; I am not nearly knowledgable enough to understand what may be wrong.
All help is appreciated :]
Block Code:

local bell = game.Workspace.bellmodel.Bell
bell.ClickDetector.MouseClick:Connect(function(click) Instance.new(“Animation”).AnimationId = “rbxassetid://”
end
)
if bell.Touched == true then click()
end

6 Likes

There are a lot of problem. First to detect when something touch the “bell” you must write : bell.Touched:Connect(function(hit) then enter

3 Likes

hey sorry i do actually have spaced between the lines however they didn’t show up in the block quote.
is this at all salvageable?
also, I’m sure you know this, the word I chose “click” is interchangeable with most anything

3 Likes

It’s okay. But you want that a animation play, right ? You maybe write the Id of the animation. Also do you want to play the animation after clicking or touching the “bell” ?

4 Likes

yeah, I was trying to make it so that a click-detector could let the player hit the bell and a short animation started, and once I’m not too lazy, a sound
also, the id is in the codeblock unless I’m misunderstanding?

4 Likes

So try to put this code :

local Bell = workspace.bellmodel.Bell

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://"

Bell.ClickDetector.MouseClick:Connect(function(player)
	local Character = player.Character
	
	if Character then
		local Humanoid = Character:WaitForChild("Humanoid")
		
		local Track = Humanoid.Animator:LoadAnimation(Animation)
		Track:Play()
	end
end)
3 Likes

ill be right back but first i want to make sure I understand this correctly.
this will start the animation when the action script function is set off by a player?
also what may be the point of the “local” things in the second function?

^ just making sure I can understand this lol :]

  • testing rn
1 Like

Yeah but we need to get the Character of the player and launch the animation with the humanoid.

2 Likes

uh the thing isnt working however it may be the clickdetector bc ur code seems to be functional, well form what I understand

1 Like

Did you put the animation id ?

2 Likes

Actually I think I forgot but the mouse cursor wont change on the bell

  • testing this too o7
1 Like


welp i gave it a shot loll
ill send a screenshot of my clickdetector in the model just to see if that is the problem

image
image

the clickdetector in the game :]

Oh yeah it’s actually strange. You should try to put a hitbox or something like that and put the ClickDetector in the part.

1 Like

will do :]
also ftr its 2:00 am by me so I might be a little slow

1 Like

Oh it’s 7:59am here :] I’m little bit slow too.

1 Like


ill keep it visible for now, Are any changes to the code needed?

Uh ok now you will put a clickDetector and inside the code you should put the name of the part.

1 Like

sorry but wdym?
also the hitbox still wont show the cursor icon
+experimenting rn lol

Oh I mean you should put the clickDetector on the HitBox like that
image

1 Like