So, Im working on making custom character controls, and ive been studying the default character control scripts and they are all local or module scripts(that run locally) and they set the humanoids movement. Does this mean that you can that you can change the character's humanoid and it will replicate to the server? Or should I use remote events for the control. I also set my game to filtering enabled and it appears the roblox defualt scripts dont use remote events, but they still replicated to the server. I was also not sure If it might be a built in roblox thing, like the core scripts. Could someone please explain.
If you are asking about how to replicate the movements of the character, you can do it by giving the client NetworkOwnership over its character, this will be the smoothest way to move their character in the view of the client.
If your game is Filtering Enabled, then you don't have to use remote events, unless your replicating the server, such as : Changing values, duplicating effects, and more on.
Speaking of character controls, you can use the UIS as shown here:
lcoal UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(Input, gameProcessedEvent) local KeyCode = Input.KeyCode if not gameProcessedEvent then -- Needed to check if the player isn't typing if KeyCode == Enum.KeyCode."keyhere" then --do your stuff here end end end)
if your gonna change any values, your gonna have to use FireServer()
with a RemoteEvent
An example is shown here;
Server Script
local Event = "writewhereyoureventis" Event.OnServerEvent:Connect(function(player) --Do your stuff here end)
Player Script
local Event = "writewhereyoureventis" Event:FireServer() -- use this when you want to call the remoteevent to do your things
If you do want to send values using FireServer
, then you can just add the value in the parenthesis like this:
Player Script
--Example: local Event = "writewhereyoureventis" local a = 0 Event:FireServer(a) -- Sends the a value
ServerScript
local Event = "writewhereyoureventis" Event.OnServerEvent:Connect(function(player, a) print(a) -- Prints the a value you send from the player script end)
Since the function already calls the player, you don't need to add another player value.
If this did help, or you have any more questions, please feel free to comment!
--YBN_oSy