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

I cant seem to make the characters head rotate for server too, why? (FE)

I am nearly there but ugh(i got the tick()bit from another tutorial)

Server

if script.Parent == workspace then script.Parent = game.StarterPlayer.StarterCharacterScripts; 
	print("Please put the 'HeadMovementServer' script into StarterPlayer.StarterCharacterScripts."); 
end;

if script.Parent == game.StarterPlayer.StarterCharacterScripts then return 
end;

local tweenService = game:GetService("TweenService");
local remote = script:FindFirstChild("Remote") ~= nil and script.Remote or Instance.new("RemoteEvent", script);

remote.Name = "Remote";

local debounce = tick();

remote.OnServerEvent:connect(function(player, mouseDirection, neck)
	if game.Players.LocalPlayer ~= nil then return 
	end;
	
	if tick()-debounce <= 0.1 then return 
	end;
	
	debounce = tick();
	tweenService:Create(neck, TweenInfo.new(0.099), {C1=(CFrame.new(Vector3.new(-0, -0.500000119, -0.000272244215)) * CFrame.Angles(mouseDirection, 0, 0))}):Play();
end)

Local

if script.Parent == workspace then script.Parent = game.StarterPlayer.StarterCharacterScripts; 
	print("Please put the 'HeadMovementServer' script into StarterPlayer.StarterCharacterScripts."); 
end;

if script.Parent == game.StarterPlayer.StarterCharacterScripts then return 
end;

local tweenService = game:GetService("TweenService");
local remote = script:FindFirstChild("Remote") ~= nil and script.Remote or Instance.new("RemoteEvent", script);

remote.Name = "Remote";

local debounce = tick();

remote.OnServerEvent:connect(function(player, mouseDirection, neck)
	if game.Players.LocalPlayer ~= nil then return 
	end;
	
	if tick()-debounce <= 0.1 then return 
	end;
	
	debounce = tick();
	tweenService:Create(neck, TweenInfo.new(0.099), {C1=(CFrame.new(Vector3.new(-0, -0.500000119, -0.000272244215)) * CFrame.Angles(mouseDirection, 0, 0))}):Play();
end)

2 comments

0

LocalPlayer will always be nil on the server. so line 16 of the server script should use the player parameter instead

0

ok, i will try

1 answer

I changed it here but i cant implement it to move the head in server

if script.Parent == workspace then script.Parent = game.StarterPlayer.StarterCharacterScripts; 
	print("Please put the 'HeadMovementServer' script into StarterPlayer.StarterCharacterScripts."); 
end;

if script.Parent == game.StarterPlayer.StarterCharacterScripts then return 
end;

local tweenService = game:GetService("TweenService");
local remote = script:FindFirstChild("Remote") ~= nil and script.Remote or Instance.new("RemoteEvent", script);

remote.Name = "Remote";

local debounce = tick();

remote.OnServerEvent:connect(function(player, HdPos, Neck)--HdPos--mouseDirection
	
	warn(player.name)
	warn(HdPos)
	
	if (player) ~= nil then return 
	end;
	
end)

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