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

Why does my remote event not fire?

Asked by 5 years ago

My code is this, for the client:

01game.ReplicatedStorage.Classes.Say.OnClientEvent:Connect(function(msg, from, inclass) -- I hope this works... - Toby
02    for i = 1, #inclass do
03        if i == game.Players.LocalPlayer.Name then
04            local gui = game.ReplicatedStorage.InClass:Clone()
05            gui.Frame.Message.Text = msg
06            gui.Frame.From.Text = from
07            gui.Parent = game.Players.LocalPlayer.PlayerGui
08            wait(3)
09            gui:Destroy()
10        end
11    end
12end)

And to fire, from the server, we do this:

1local playerTable = {player.Name}
2game.ReplicatedStorage.Classes.Say:FireAllClients("Secret society doesn't work!", "Server Message!", playerTable)
3print(player.Name)
4print("This place hasn't been made!")

The prints, on the server script, fires. But the Gui doesn't pop up, and worse of all, there are no errors...

Thanks for reading this, I really hope that you can help me. - Toby

0
For client, Change "if i == game.Player.LocalPlayer.Name then" to "if inclass[i] == game.Players.LocalPlayer.Name then" Trading_Opportunity 191 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

uh i think these

1local playerTable = {player.Name}
2repeat
3wait(0.2)
4game.ReplicatedStorage.Classes.Say:FireServer("Secret society doesn't work!", "Server Message!", playerTable)
5until game.ReplicatedStorage.Classes.Say:FireServer("Secret society doesn't work!", "Server Message!", playerTable)
0
This just made the prints, on server script, not print... : ( tobiO0310 58 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I found out that "i", on the local script, is a number, not a name. And I edited LocalPlayer.PlayerGui, to something else. So my local script should look like this:

01game.ReplicatedStorage.Classes.Say.OnClientEvent:Connect(function(msg, from, inclass) -- I hope this works... - Toby
02    for i = 1, #inclass do
03        if inclass[i] == game.Players.LocalPlayer.Name then
04            local gui = game.ReplicatedStorage.InClass:Clone()
05            gui.Frame.Message.Text = msg
06            gui.Frame.From.Text = from
07            local localplayerName = game.Players.LocalPlayer.Name
08            gui.Parent = game.Players:FindFirstChild(localplayerName).PlayerGui
09            wait(3)
10            gui:Destroy()
11        end
12    end
13end)

Thanks for reading this. - Toby

Answer this question