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

Why Does This Client Sided Rotation Script Rotate On The Server?

Asked by 3 years ago

Hello, I made a pet and I would like for one part of the pet to rotate on the client, so that the rotation doesn't lag.

However, for some reason, it seems that it makes the whole pet model rotate, on the server only. On the client, it works perfectly. This is the server sided pet follow script

local pet = workspace:WaitForChild("FlyingEmojiTemplate")
local runService = game:GetService("RunService")
local remoteEvent = game.ReplicatedStorage:WaitForChild("turnFan")


function givePet(player)
    wait(5)

    if player then
        local character = player.Character
        if character then

            local humRootPart = character.HumanoidRootPart
            local newPet = pet:Clone()
            newPet.Name = "FlyingEmoji"
            newPet.Parent = game.Workspace

            local head = newPet.HeadEmoji
            local heliCopter = newPet.HeliCopter
            local sunGlasses = newPet.SunGlasses

            head.Anchored = false

            head:SetNetworkOwner(player)
            heliCopter:SetNetworkOwner(player)
            sunGlasses:SetNetworkOwner(player)
            newPet.Parent = character

            remoteEvent:FireAllClients(heliCopter)

            local bodyPos = Instance.new("BodyPosition", head)
            bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

            local bodyGyro = Instance.new("BodyGyro", head)
            bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)


            local rv = bodyGyro.CFrame.rightVector

            runService.Stepped:Connect(function()
                bodyPos.Position = humRootPart.Position + Vector3.new(1, 1, 2)
                bodyGyro.CFrame = humRootPart.CFrame * CFrame.Angles(0, math.rad(90), 0)

            end)

        end
    end


end

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        givePet(player)
    end)
end)

This is a localscript inside replicated First

local runService = game:GetService("RunService")
local remoteEvent = game.ReplicatedStorage:WaitForChild("turnFan")

remoteEvent.OnClientEvent:Connect(function(part)
    runService.Stepped:Connect(function()
        part.Orientation = part.Orientation + Vector3.new(0, 5, 0)
    end)

end)

The rotating Part is welded to the pet model.

0
When firing to all clients it happens at the same time on every client, so it looks like its happening on the server. MarkedTomato 810 — 3y
0
Do other's pets rotate on your side? sne_123456 439 — 3y
0
I don't think thats the case, https://gyazo.com/a55e6bf7e537dfa2dd9ce221d987ac4d mariohead13 129 — 3y
0
this is what other player's see https://gyazo.com/9c9f4dc20e81aaa9310bb399c806f887 mariohead13 129 — 3y
0
If i stop the rotation, everything works fine https://gyazo.com/500da516ac986d39cc0e7cf46c27f64b mariohead13 129 — 3y

Answer this question