Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How is it possible to replicate a string value from client to server?

So right now, I have a localscript:

script.Parent.Frame.Confirm.MouseButton1Click:Connect(function()
	script.Parent.Enabled = false
	game.Workspace.Text.SurfaceGui.TextLabel.Text = script.Parent.Frame.TextProduct.Text .. " $" .. script.Parent.Frame.TextPrice.Text
	game.ReplicatedStorage.Sign.Value = script.Parent.Frame.TextProduct.Text .. " $" .. script.Parent.Frame.TextPrice.Text
end)

I also have a script:

while true do
	print(game.ReplicatedStorage.Sign.Value)
	game.Workspace.Text.SurfaceGui.TextLabel.Text = game.ReplicatedStorage.Sign.Value
	wait(1)
end

When printing, it prints nothing because that is how the string value starts.. It shows up on the client, but when on the server the string value doesn't change. I thought you could change a value on the client and it would replicate to the server in ReplicatedStorage, but I don't know how. How would I do this?

1 answer

Use RemoteEvents.

Read this to know more: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

BTW...

Client:

local remoteEvent = game.ReplicatedStorage.RemoteEvent

script.Parent.Frame.Confirm.MouseButton1Click:Connect(function()	
	remoteEvent:FireServer()
end)

Server:

local remoteEvent = game.ReplicatedStorage.RemoteEvent

remoteEvent.OnServerClient:Connect(function(player)
	script.Parent.Enabled = false
	game.Workspace.Text.SurfaceGui.TextLabel.Text = script.Parent.Frame.TextProduct.Text .. " $" .. script.Parent.Frame.TextPrice.Text
	game.ReplicatedStorage.Sign.Value = script.Parent.Frame.TextProduct.Text .. " $" .. script.Parent.Frame.TextPrice.Text
end)

^Make sure ServerScript and LocalScript have the same parent ig or just modify the locations in the script if that isn't possible.

This discussion is preserved as it was. New answers, comments, and votes are closed.