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

Two players cant use an animation at the same time?

Asked by 4 years ago
Edited 4 years ago

Strange glitch is appearing in my game when one player is actively using an animation and another player click the button to active their animation it will just deactivate the other players animation. If anyone knows why this is and can help me fix it that would be very helpful (:

Video showcasing glitch: https://youtu.be/mmn5RjQipkI

The local script use to detect when a player is using the animation.

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

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

UserInputService.InputBegan:Connect(atease)

A regular script used to animate the character.

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 -- Same as "if active == false"

    activeAtEase = true --change debounce 

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 --if active was true:

activeAtEase = false

    animTrack:Stop()

    end

end

AEremote.OnServerEvent:Connect(onAtEaseFire)



------------------Salute


function OnSaluteFire(plr)

if not activeSalute then -- Same as "if active == false"

    activeSalute = true --change debounce 

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

local humanoid = char.Humanoid

local animation = Instance.new("Animation")

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



animTrack = humanoid:LoadAnimation(animation)

    animTrack:Play()

else --if active was true:

activeSalute = false

    animTrack:Stop()

    end

end

Sremote.OnServerEvent:Connect(OnSaluteFire)


----------------Crouch

function OnCrouchFire(plr)

if not activeCrouch then -- Same as "if active == false"

    activeCrouch = true --change debounce 

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

local humanoid = char.Humanoid

local animation = Instance.new("Animation")

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



animTrack = humanoid:LoadAnimation(animation)

    animTrack:Play()

else --if active was true:

activeCrouch = false

    animTrack:Stop()

    end

end

Cremote.OnServerEvent:Connect(OnCrouchFire)
1
Player animations should be done in local scripts not on the server User#5423 17 — 4y
0
animations are automatically played across the server from the client so their is no need to have it done on a serversided script. it is also easier if its done locally xXmacerofXx 29 — 4y

Answer this question