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

My animation script only works within studio test mode?

Gday, I have made some scripts for animations but they only work in studio not in game. I am wondering why this is. The scripts are filtering enabled but they just don't work in game. Does anyone know whats wrong with them?

Heres the scripts below. No errors are returned in studio or in game. If anyone can see the problem and can help out, I'd appreciate it.

AnimationHandlerScript Class: Script Location: SeverScriptService

math.randomseed(tick())

local rs = game:GetService("ReplicatedStorage")
local AEremote = rs.AnimAtEase
local Sremote = rs.AnimSalute
local Cremote = rs.AnimCrouch
local animations = {03174847886}
local animations2 = {03174855696}
local animations3 = {03174837885}
local activeAtEase = false
local activeSalute = false
local activeCrouch = false


  

function onAtEaseFire(plr)

if not activeAtEase then

	activeAtEase = true 

local char = game.Workspace:FindFirstChild(plr.Name)

local humanoid = char.Humanoid

local animation = Instance.new("Animation")

	animation.AnimationId = "rbxassetid://"..animations[math.random(1, #animations)]

  

animTrack = humanoid:LoadAnimation(animation)

	animTrack:Play()

else 

activeAtEase = false

	animTrack:Stop()

	end

end

AEremote.OnServerEvent:Connect(onAtEaseFire)

AtEaseScript Class: LocalScript Location: StaterPlayer.StarterCharacterScripts

local UserInputService = game:GetService("UserInputService")
local rs = game:GetService("ReplicatedStorage")
local AnimAtEase = rs:WaitForChild("AnimAtEase")

local function atease(inputObject, gameProcessed)
	if inputObject.KeyCode == Enum.KeyCode.X then
		AnimAtEase:FireServer()
	end
end

UserInputService.InputBegan:Connect(atease)

1 answer

The variables at the start of the script are all affected by EVERY player that fires the event. You may need to do a different system to know whether players are saluting or not

Some fixes can be otherwise:

line #23 | local char = plr.Character
line #27 | local animation = Instance.new("Animation", plr.Character)

Side Note: I believe that you can make this much simpler if you did this on the client-side. Animations played from local scripts onto character humanoids, replicate to other clients.

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