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

Why server is not replicating to client?

Asked by 7 years ago

Hello, I am trying to animate a plane and I am using Motor6D to do so. The plane I am using is run on a LocalScript so I used a RemoteEvent to tell a server Script to animate the plane. But the issue is that the animation is played on the server side but not replicated to each client and I have no idea how to do so. Can someone help me.

Here are the scripts just encase needed.

LocalScript

function changeGear()
    local runAnimationsEvent = game.ReplicatedStorage:WaitForChild("runAnimationsEvent")
    if game.Players.LocalPlayer.Character.Plane.GearOn.Value == true then
        runAnimationsEvent:FireServer(game.Players.LocalPlayer.Character.Plane.GearOn.Value)
        wait(10)
        game.Players.LocalPlayer.Character.Plane.GearOn.Value = false
    else
        runAnimationsEvent:FireServer(game.Players.LocalPlayer.Character.Plane.GearOn.Value)
        wait(10)
        game.Players.LocalPlayer.Character.Plane.GearOn.Value = true
    end
end

Server Script

local runAnimationsEvent = Instance.new("RemoteEvent", game.ReplicatedStorage)
runAnimationsEvent.Name = "runAnimationsEvent"

runAnimationsEvent.OnServerEvent:Connect(function(player, gearOn)
    if gearOn == true then
        player.Character.Plane.MainParts.Animations.FrontGear.Motor:SetDesiredAngle(3.3)
        player.Character.Plane.MainParts.Animations.RightGear.Motor:SetDesiredAngle(-1.5)
        player.Character.Plane.MainParts.Animations.LeftGear.Motor:SetDesiredAngle(1.5)
    else
        player.Character.Plane.MainParts.Animations.FrontGear.Motor:SetDesiredAngle(0)
        player.Character.Plane.MainParts.Animations.RightGear.Motor:SetDesiredAngle(0)
        player.Character.Plane.MainParts.Animations.LeftGear.Motor:SetDesiredAngle(0)
    end
end)

Answer this question