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
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!