Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago

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

0
this so old, so mich deprecation, definately model Ziffixture 6913 — 5y
0
Yes I used a model and then edited it to make it work for me SpacePuppyMan 31 — 5y
0
It's still very broken, let me fix it up, I'll post it in asnwers Ziffixture 6913 — 5y
0
Thanks SpacePuppyMan 31 — 5y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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!

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! Ziffixture 6913 — 5y
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 Ziffixture 6913 — 5y
0
What type of Script is this? where is it located too? Ziffixture 6913 — 5y
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. SpacePuppyMan 31 — 5y
View all comments (14 more)
0
Okay, let me take a look Ziffixture 6913 — 5y
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 Ziffixture 6913 — 5y
0
Abstract meaning existant, not not physically accessible Ziffixture 6913 — 5y
0
if 'Good' doesn't fire in the output, let me know, if this works, don't forget to press accept! Ziffixture 6913 — 5y
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 Ziffixture 6913 — 5y
0
It's printing 'Good' In the output but I'm getting this error 'Workspace.Script:9: attempt to index a nil value' SpacePuppyMan 31 — 5y
0
wait, my apologies don't destroy the original, it'll break it Ziffixture 6913 — 5y
0
Sorry, I spelt something wring, let me quickly add a few updates Ziffixture 6913 — 5y
0
There, also make sure the localscript is disabled, it'll re enable it when it gets transferred Ziffixture 6913 — 5y
0
hmm It's printing 'Good' in the output and there is no errors but the players animation isn't changing SpacePuppyMan 31 — 5y
0
Unfold the Player, tell me if the Script is in the proper location Ziffixture 6913 — 5y
0
Yeah the script isn't inside the player SpacePuppyMan 31 — 5y
0
Still in the part, I changed it to StarterCharacter, try that Ziffixture 6913 — 5y
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 Ziffixture 6913 — 5y
Ad

Answer this question