Object not Replicating on Server

So this Script spawns a Stage but its not replicating on the server only on the client i know about remote events but have no knowledge of them how would i make a server script for this

1st image is Client
image
2nd is Server
image

print(script.Parent.Parent.Name)

local Plr = game.Players.LocalPlayer

local RPS = game:GetService(“ReplicatedStorage”)

local Stages = RPS:WaitForChild(“Stages”)

local Stands = workspace.Stands

local PlayerStand = workspace.Stands:WaitForChild(Plr.Name)

local Base = PlayerStand.Base

local Button = script.Parent

local GUI = Plr.PlayerGui:WaitForChild(“CloneUI”)

local Stage = Stages:WaitForChild(script.Parent.Parent.Name)

Button.MouseButton1Click:Connect(function(Clone)

Stage = Stage:Clone()

Stage.Parent = PlayerStand

Stage.Name = “Stage”

Stage:MoveTo(Base.SpawnPoint.Position)

GUI.ScrollingFrame.Visible = false

GUI.TextLabel.Visible = false

end)

1 Like

You would fire a RemoteEvent from the client to the server (LocalScript to Script). From there, you have the server script spawn the stage.

Example:

LocalScript:

Button.MouseButton1Click:Connect(function()
   ReplicatedStorage.CloneStage:FireServer()
end)

Server script:

ReplicatedStorage.CloneStage.OnServerEvent:Connect(function(player)
   --//clone your stage here
end)
1 Like

adding on to this

you will also need to provide the actual stage and position. you can tell the server the location by doing something like this

Client

Button.MouseButton1Click:Connect(function()
     -- UI Stuff
     ReplicatedStorage.CloneStage:FireServer(Stage, Base.SpawnPoint.Position)
end)

Server

ReplicatedStorage.CloneStage.OnServerEvent:Connect(function(player, stage, position)
     local Stage = stage:Clone()
     -- other stuff
     Stage:MoveTo(position)
end)

you can also just look for them on the server itself, but in my opinion it feels more messier. there are better solutions too, this is just the first one that popped up in my head.

1 Like