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

How can I make my Remote Event create TextButtons Online?

I'm having trouble making a script that uses a Remote Event work Online. It works fine in studio, but nothing happens elsewhere. I'm using a Remote Event because scripting without this did not work either. I'm just trying to create 3 TextButtons, nothing more. Any and all help is appreciated.

P.S Please don't direct to the "It works fine in Studio but not online" page.

Server Script:

script.Parent.Order.MouseButton1Click:connect(function()
	Events.OrderParts:FireServer()
end)

Remote Event:

script.Parent.OnServerEvent:connect(function()
	local TextButton1 = Instance.new("TextButton", script.Parent.Parent.Parent)
	local TextButton2 = Instance.new("TextButton", script.Parent.Parent.Parent)
	local TextButton3 = Instance.new("TextButton", script.Parent.Parent.Parent)
	
	TextButton1.Text = "Order CPU's"
	TextButton1.TextColor3 = Color3.new(255, 255, 255)
	TextButton1.Font = Enum.Font.SourceSansItalic
	TextButton1.BackgroundTransparency = 0.8
	TextButton1.Position = UDim2.new(0.8, 0,0.2, 0)
	TextButton1.Size = UDim2.new(0, 200,0.05, 50)
	TextButton1.TextScaled = true
	TextButton1.Name = "OrderCPU"
	
	TextButton2.Text = "Order Cases"
	TextButton2.TextColor3 = Color3.new(255, 255, 255)
	TextButton2.Font = Enum.Font.SourceSansItalic
	TextButton2.BackgroundTransparency = 0.8
	TextButton2.Position = UDim2.new(0.8, 0,0.35, 0)
	TextButton2.Size = UDim2.new(0, 200,0.05, 50)
	TextButton2.TextScaled = true
	TextButton2.Name = "Ordercase"
	
	TextButton3.Text = "Cancel"
	TextButton3.TextColor3 = Color3.new(255,255,255)
	TextButton3.Font = Enum.Font.SourceSansItalic
	TextButton3.BackgroundTransparency = 0.8
	TextButton3.Position = UDim2.new(0.53, 0,0.27, 0)
	TextButton3.Size = UDim2.new(0, 200, 0.05, 50)
	TextButton3.TextScaled = true
	TextButton3.Name = "Cancel"
end)

4 comments

0

Why are you using OnServerEvent on the client?

0

Use OnClientEvent not OnServerEvent

0

Is the RemoteEvent script a local script?

0

You also can't FireServer() from the server. Look at a remote event tutorial dude.

1 answer

✓ Accepted answer

You might want to read over the RemoteEvent documentation, since you're confusing a lot of functions. I'll list them here for you:


Use on server scripts only:

  • :FireClient(player) - Fires the event for only
  • :FireAllClients() - Fires the event for all clients
  • .OnServerEvent(player) - Fires when the event is fired from client

Use on local scripts only:

  • :FireServer() - Fires the event on the server
  • .OnClientEvent() - Fires when the event is fired from the server

Your script works in studio but not online because Studio doesn't really make a distinction between the client and the server. Make sure you're using all of these events correctly and your script should work fine.

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