I'm trying to make a gui so that when you click it, an amount of parts spawn.
I also have a gui to determine how many parts to spawn, this is where I'm stuck.
Server Script
game.ReplicatedStorage.CreateEvent.OnServerEvent:Connect(function(player) print("Works!") CA = game.ReplicatedStorage.CreateAmount.Value for i = 1, CA do wait(0.2) local deathPart = game.ReplicatedStorage.F9 wait(0.2) local F9C = deathPart:Clone() wait(0.2) F9C.Parent = game.workspace.F9Parent F9C.Position = Vector3.new(math.random(-590,-460), 57, math.random(-170,60)) end end)
Local Script
script.Parent.MouseButton1Click:Connect(function() while true do game["Run Service"].RenderStepped:wait() script.Parent.Text = game.Players.LocalPlayer:WaitForChild("PlayerGui").ScreenGui3.TextBox.Text game.ReplicatedStorage.CreateAmount.Value = script.Parent.Text end end)
Even if I change the Number Value in develop mode, it still doesn't spawn any parts and only prints "Works!" once.
ReplicatedStorage is on the server and replicated to every client. Client-Server Model
the line: game.ReplicatedStorage.CreateAmount.Value = script.Parent.Text
changes the value of CreateAmount on the players' computer and not the actual server so the server will always make the default number.
I suggest that you simply send the amount you want to be created as an argument in the remote event.
Server
game.ReplicatedStorage.CreateEvent.OnServerEvent:Connect(function(player, CA) print("Works!") for i = 1, CA do wait(0.2) local deathPart = game.ReplicatedStorage.F9 wait(0.2) local F9C = deathPart:Clone() wait(0.2) F9C.Parent = game.workspace.F9Parent F9C.Position = Vector3.new(math.random(-590,-460), 57, math.random(-170,60)) end end)
Client
script.Parent.MouseButton1Click:Connect(function() script.Parent.Text = game.Players.LocalPlayer:WaitForChild("PlayerGui").ScreenGui3.TextBox.Text game.ReplicatedStorage.CreateEvent:FireServer(script.Parent.Text) end end)