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

How do i play a animation serverside?

rs = game:GetService("ReplicatedStorage")
ss = game:GetService("ServerStorage")

rs.q.OnServerEvent:Connect(function(player)
    local NewChar = ss.Rogue:Clone()
    local Pos = player.Character:GetPrimaryPartCFrame()
    local animation = script:WaitForChild('Animation')
    local Character = player.Character
    local humanoid = Character:WaitForChild("Humanoid")
    local fall = humanoid:LoadAnimation(animation)
    player.Character :Destroy()
    player.Character = NewChar
    NewChar.Parent = workspace
    NewChar:SetPrimaryPartCFrame(Pos)
    wait(60)
    fall:Play()
    player:LoadCharacter()


end)

thats the script but i think the way i did it is for local script

1 answer

✓ Accepted answer

What you need is Local Script/ RemoteEvent/ Server Script

I'll show you an example Local Script'

Player = game.Players.LocalPlayer
repeat wait() until Player.Character
Character = Player.Character
Remote = script.Function


script.Parent.Activated:Connect(function()

Remote:FireServer()

	end
end)

Server Script

Remote = script.Parent

Remote.OnServerEvent:Connect(function(player)
	local Track = Instance.new("Animation")
	Track.AnimationId = "rbxassetid://"
	local Anim = c.Humanoid:LoadAnimation(Track)
	Anim:Play()
end)

And that's all.

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