Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make my Remote Event create TextButtons Online?

Asked by 7 years ago

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)
0
Why are you using OnServerEvent on the client? NewVoids 97 — 7y
0
Use OnClientEvent not OnServerEvent MrLonely1221 701 — 7y
0
Is the RemoteEvent script a local script? AstrealDev 728 — 7y
0
You also can't FireServer() from the server. Look at a remote event tutorial dude. cabbler 1942 — 7y

1 answer

Log in to vote
0
Answered by
P100D 590 Moderation Voter
7 years ago
Edited 7 years ago

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 <player>
  • :FireAllClients() - Fires the event for all clients
  • .OnServerEvent(player) - Fires when the event is fired from client <player>

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.

Ad

Answer this question