Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Button changing everyone's animation in the server instead of one player?

Hi, I'm trying to create a button / part which when clicked changes a players animation e.g. from default to levitation, using the Roblox animation packs in the catalog. My problem is that I only want it to effect the local player and not everyone else. Right now I have a script in workspace with the localscript for the animation pack as it's child. It works well but the script changes everyone animation not just the one player. I think to achieve what I won't I would have to use a localscript but I'm not sure how I would translate the code into one.

Here's my script:

l=script:WaitForChild'Animate':clone()
workspace.DescendantAdded:connect(function(v)
			game.Workspace.Click2.ClickDetector.MouseClick:Connect(function()

if v.Name=='Animate' then
local c=l:clone()
c.Parent=v.Parent
v:Destroy()
wait()
c.Disabled=false
end
			end)
			end)

Thanks

4 comments

0

this so old, so mich deprecation, definately model

0

Yes I used a model and then edited it to make it work for me

0

It's still very broken, let me fix it up, I'll post it in asnwers

0

Thanks

1 answer

✓ Accepted answer

This should do it for you

local Animation = script:WaitForChild("Animate"):Clone()
Animation.Parent = workspace:WaitForChild("Click2") --// Set inside of ClickPart
workspace.DescendantAdded:Connect(function(Descedant) --// Fire when sent to workspace
   local ClickDetector = Animation.Parent:FindFirstChildWhichIsA("ClickDetector") --// Get ClickDetector
   ClickDetector.MouseClick:Connect(function(Player)
      if (Descendant.Name == "Animate") then print("Good") --// test purposes
         if (Player) then --// precautionary messure
            Animation.Parent = Player:FindFirstChild("StarterCharacterScripts") --// Sets Parent to Player
            Animation.Disabled = false
         end
      end
   end)
end)

Hope it works!

18 comments

0

Your script was a bit hard to understand, tweek it up and repost it as an edit to your question, I'll try to fix your problem from there, unless somehow this cleanup fixed your issues, then don't forget to press accept answer!

0

Could you actually explain to hme what you're trying to do? With detail, I need to know all the Objects, where they're located and where they will be, etc

0

What type of Script is this? where is it located too?

0

So I've got a script in workspace with a Localscript as a child of it. The script is basically suppose to clone the Localscript called 'Animate' into the player and the localscript will handle the rest. My problem is that the script, being a script not a Localscript is cloning the Localscript called 'Animate' Into everyone in the server not just the player who clicked the button / part.

0

Okay, let me take a look

0

Okay, that should do it, it's a very odd method of transferring something but okay. also make sure Click2 is a part, because the ClickDetector primarily has to be inside of a part to fire, not a Script, a Script is abstract

0

Abstract meaning existant, not not physically accessible

0

if 'Good' doesn't fire in the output, let me know, if this works, don't forget to press accept!

0

if the tansaction doesn't work, or if theres an error, read it to me, it may require FE, if it does I can easily edit my answer and give you insructions from there on how to fix it

0

It's printing 'Good' In the output but I'm getting this error 'Workspace.Script:9: attempt to index a nil value'

0

wait, my apologies don't destroy the original, it'll break it

0

Sorry, I spelt something wring, let me quickly add a few updates

0

There, also make sure the localscript is disabled, it'll re enable it when it gets transferred

0

hmm It's printing 'Good' in the output and there is no errors but the players animation isn't changing

0

Unfold the Player, tell me if the Script is in the proper location

0

Yeah the script isn't inside the player

0

Still in the part, I changed it to StarterCharacter, try that

0

Theres a Folder inside of the zpkayer, you need to check that, it is either in StaterPlayer or StarterCharacter, it'll be crammed in eith some defualt Scripts so look carefully

This discussion is preserved as it was. New answers, comments, and votes are closed.