Why is my server script acting client-sided?

Here’s a video:


If you didn’t notice, client sided in studio works perfectly, just how I want it too. When I switch to server sided, the frogs rotation breaks. In-game, the frogs animations don’t work anymore but they do rotate. I’m so confused, here is the script to the frog moving:

local root = script.Parent.Parent.PrimaryPart
game:GetService("ReplicatedStorage").FrogCam.OnServerEvent:Connect(function(player, target)
	if target == script.Parent.Parent then
		game.Players[player.Name].Character.Humanoid.WalkSpeed = 0
		game.Players[player.Name].Character.Humanoid.JumpPower = 0
		script.Parent.Parent.PlayerPosition.WeldToPlayer.Part1	= game.Players[player.Name].Character.HumanoidRootPart
		game.Players[player.Name].Character.Humanoid:LoadAnimation(script:WaitForChild("PlayerKneel")):Play()
		script.Disabled = true
	end
end)
while true do wait(math.random(1,5))
	local randomnumber = math.round(math.random(1,3))
	if randomnumber == 1 then
		root.Orientation = Vector3.new(0,math.random(0,360),0)
	end
	local humanoid = script.Parent
	local f = humanoid:LoadAnimation(script:WaitForChild("Jump"))
	f:Play()
	wait(.2)
	for i = 1, 6 do wait()
		root.CFrame = root.CFrame + root.CFrame.lookVector * -1
	end
end

Once again, this is 100% a server script, recommended for NPC animations.

1 Like

Try doing rootPart:SetNetworkOwner(nil) to make the npc owned by the server.

Hello, thank you for your reply

image
I put it right there but it didn’t work, is there somewhere else I should put it?
I also tried using that function on the humanoid.

You should set the NPC model’s network owner to nil instead of the PrimaryPart of the model.

Thank you for your reply,

I set the npcs model network owner to nil, still nothing

First of all, I recommend using task.wait instead of wait
Second of all, math.random does not return float values, so there’s no need to use math.round on the variable randomnumber

Now try this and tell me if it works.

local root = script.Parent.Parent.PrimaryPart
local humanoid = script.Parent
local animationtrack = humanoid:LoadAnimation(script:WaitForChild("Jump"))

root:SetNetworkOwner(nil)

game:GetService("ReplicatedStorage").FrogCam.OnServerEvent:Connect(function(player, target)
	if target == script.Parent.Parent then
		game.Players[player.Name].Character.Humanoid.WalkSpeed = 0
		game.Players[player.Name].Character.Humanoid.JumpPower = 0
		script.Parent.Parent.PlayerPosition.WeldToPlayer.Part1	= game.Players[player.Name].Character.HumanoidRootPart
		game.Players[player.Name].Character.Humanoid:LoadAnimation(script:WaitForChild("PlayerKneel")):Play()
		script.Disabled = true
	end
end)

while true do 
    task.wait(math.random(1,5))
	local randomnumber = math.random(1,3)
	if randomnumber == 1 then
		root.Orientation = Vector3.new(0,math.random(0,360),0)
	end
	
	animationtrack:Play()
	task.wait(.2)
	for i = 1, 6 do wait()
		root.CFrame = root.CFrame + root.CFrame.lookVector * -1
	end
end

Thank you for your reply,

The NPC’s still appear to not rotate.

If you are using server mode to try and see if it replicates then don’t, use 2 player mode.
FYI rotation doesn’t work on server mode.

image
I guess I should’ve mentioned that my NPC’s are anchored

Alright remove the SetNetworkOwner part of your script as it serves no use since no can get ownership over an anchored part, then try again.

EDIT: Fixed typo

I unanchored the NPC, it gives me the same error.

ReAnchor it then do what I said above then try again.

Thank you for your reply,

Here’s what I noticed, I originally only anchored the HumanoidRootPart, when I anchored the entire model, the rotations in the studio server were working, but the frogs weren’t moving or having their animations played. In studio client sided, and in-game is acted the exact same. Nothing changed.

Try 2 player mode and see if it only happens to studio server.

Thank you for your reply

I would but I don’t have a second person

Go to the Test tab in the studio and set the server population to 2 Players, and then Start Server via the server icon in the same tab. This will create three window, with one of them being the server-sided view and the other two windows being separate clients.

Doing this will allow you to do multiplayer testing without the need of another person.

There’s a 2 player mode in studio

image

Change that to 2 players and press Start.

I set it to 2 player, when I pressed play, it sets back to 1 player. If that’s normal, then client works, once again, server doesn’t work.

I pressed “Start” and it kept it, however still, client works, server doesn’t

So on both of the clients it didn’t Jump/Rotate?