Help me "convert" my localscript into a serverscript

Hello, I’m doing a character creation, and it has a Body Size part
However it is in localscript and I’m not getting it as a script that executes a function when a RemoteEvent fires the server

--Starting Script

script.Parent.MouseButton1Click:Connect(function()
	local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
	local BDS = Humanoid.BodyDepthScale
	local BWS = Humanoid.BodyWidthScale
	local BHS = Humanoid.BodyHeightScale
	local HS = Humanoid.HeadScale
	
	HS.Value = 0.8499999999999999778
	BDS.Value = 1
	BWS.Value = 1
	BHS.Value = 1
end)

In the script, instead of working for a specific number, I want it to be any number. I tried to do this but it didn’t work : /

This is the server script i failed to do:

local event = Instance.new("RemoteEvent")
event.Name = "BodySizeEvent"
event.Parent = game.Workspace["Events"]["TheEvents"]

event.OnServerEvent:Connect(function(humanoid, value1, value2, value3, value4, value5, value6, value7, value8)

	Humanoid.value1 = value5
	Humanoid.value2 = value6
	Humanoid.value3 = value7
	Humanoid.value4 = value8

end)
1 Like

I’m a bit confused as to what you mean exactly. But from what I understand, the server script won’t execute that code you showed in the post (the server script you failed to do)?

It’s likely because the server can’t access “humanoid”, as it is in LocalPlayer, which is only accessible from the client-side, not the server.

And, where are you firing the Remote Event? Could you share the code for the LocalScript that fires the Remote Event to the server?

And also, I’m a bit confused as to what you’re doing here. You receive “humanoid” in the parameters (with no capital letters), but then you change the values for “Humanoid” (which has a capital H). Is that a typo?

Hope I can be of some help.

When connecting a remote event on the server the first argument is the player, then is what you sent in the remote, so you do no need to send the humanoid argument, also, ensure you find some way of validating this remote event.

event.OnServerEvent:Connect(function(Player)
	local Character = Player.Character or Player.CharacterAdded:Wait()
    local Humanoid = Character:WaitForChild("Humanoid")
end)
1 Like

Error:
11:55:52.610 - BodyDepthScale is not a valid member of Humanoid

LocalScript:

--Creating Variables
local hum = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

local headScale = Instance.new("NumberValue")
headScale.Name = "HeadScale"
headScale.Parent = hum
headScale.Value = 0.8499999999999999778

local hum = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")


local BodyDepthScale = Instance.new("NumberValue")
BodyDepthScale.Name = "BodyDepthScale"
BodyDepthScale.Parent = hum
BodyDepthScale.Value = 1

local BodyWidthScale = Instance.new("NumberValue")
BodyWidthScale.Name = "BodyWidthScale"
BodyWidthScale.Parent = hum
BodyWidthScale.Value = 1

local BodyHeightScale = Instance.new("NumberValue")
BodyHeightScale.Name = "BodyHeightScale"
BodyHeightScale.Parent = hum
BodyHeightScale.Value = 1


--Starting Script

script.Parent.MouseButton1Click:Connect(function()
game.Workspace.Events.TheEvents.BodySizeEvent1:FireServer(game.Players.LocalPlayer)
end)

RemoteEvent’s Script

-- New Server Script
local event1 = Instance.new("RemoteEvent")
event1.Name = "BodySizeEvent1"
event1.Parent = game.Workspace["Events"]["TheEvents"]
local event2 = Instance.new("RemoteEvent")
event2.Name = "BodySizeEvent2"
event2.Parent = game.Workspace["Events"]["TheEvents"]
local event3 = Instance.new("RemoteEvent")
event3.Name = "BodySizeEvent3"
event3.Parent = game.Workspace["Events"]["TheEvents"]


event1.OnServerEvent:Connect(function(Player)
	
	------------------- The Script.
	print("fired")
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character.Humanoid
local BDS = Humanoid.BodyDepthScale
local BWS = Humanoid.BodyWidthScale
local BHS = Humanoid.BodyHeightScale
	local HS = Humanoid.HeadScale
	print("variables")
	
HS.Value = 0.8499999999999999778
BDS.Value = 1
BWS.Value = 1
	BHS.Value = 1.0499999523162841797
	print("code")
-------------------


end)