How can I make it so that parts that I clone on the client can be seen by the entire server while still being on the client side?
So right now in my game, I have a system where you click, your head gets cloned and that head is just part of you now until you sell. However, when there is a certain amount of heads that spawn, people in the server start to lag because the parts are cloned to the server.
What I want to find out is how can I still clone the head of the player that clicked locally and other people are still able to see it without affecting their performance?
(I know I have to use multiple RemoteEvents but I’m having trouble with the last client sided script) Client > Server > Client --This last script
What you’re trying to do sounds like using Network Ownership, which is generally discouraged because of vulnerability exploits
If you still wanna try, just create the part on the server, set its network owner to the player, and have that player manipulate the part in a localscript https://developer.roblox.com/en-us/api-reference/function/BasePart/SetNetworkOwner
It’s basically unavoidable; so long as the client is in charge of something, there’s going to be the risk of them doing unforeseen evils
The original method you described isn’t any better, the client can just hijack the remote to send modified information with malicious intent
I guess you have to just do everything on the server, even if it means causing lag, safety comes first
Actually, it really just depends on the use case. Network ownership shouldn’t be used on any critical game mechanics, but for simpler processes like visual effects it should be fine, you’ll just have to implement a lot of security checks to make sure they can’t do anything bad like teleport blocks into other player’s face
So before on a different post, someone suggested to use :FireAllClients and use that in a local script to display all the players cloned heads. Does that still require using Network Ownership?
It is essentially the same as Network Ownership in that it is equally vulnerable, you’re still giving the client power to control and manage objects that are seen by everyone
Make a system when the player clicks it fires a remote to the server, when the server receives the button press from the remote, fire to all clients a remote that will clone the head, that way the head will be on everyone’s client.
The last script is where you actually clone the head.
As I asked in a previous post, how exactly do I do that? I know how to send the remote to server, then the server sends a remote to the client again BUT I’m not sure how to clone the head onto the player that clicked locally and still make it show to everyone else.
I tried using :FireAllClients: but it didn’t work so do you have any suggestions?
UserInputService.InputBegan:Connect(function(input)
if h.Value < ContainerSpace.Value then
if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
event:FireServer()
end
end
end)
The problem is when you fire all clients your not specifying which player to clone the head to, your not sending the “player who the head should be cloned for” over to all clients from the server.
In the first script you should add the following:
local localPlayer = game.Players.LocalPlayer
local playerWhoHeadToClone = localPlayer
-- your code here
Event:FireServer(playerWhoHeadToClone)
-- your code etc
Hey there I know it’s been a week but I tested the game out and I can see the problem. How can I fix the blocks to spawn only on the player that clicks and not everyone in the server?