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 4 years ago

My code is this, for the client:

game.ReplicatedStorage.Classes.Say.OnClientEvent:Connect(function(msg, from, inclass) -- I hope this works... - Toby
    for i = 1, #inclass do
        if i == game.Players.LocalPlayer.Name then
            local gui = game.ReplicatedStorage.InClass:Clone()
            gui.Frame.Message.Text = msg
            gui.Frame.From.Text = from
            gui.Parent = game.Players.LocalPlayer.PlayerGui 
            wait(3)
            gui:Destroy()
        end
    end
end)

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

local playerTable = {player.Name}
game.ReplicatedStorage.Classes.Say:FireAllClients("Secret society doesn't work!", "Server Message!", playerTable)
print(player.Name)
print("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 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

uh i think these

local playerTable = {player.Name}
repeat
wait(0.2)
game.ReplicatedStorage.Classes.Say:FireServer("Secret society doesn't work!", "Server Message!", playerTable)
until 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 — 4y
Ad
Log in to vote
0
Answered by 4 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:

game.ReplicatedStorage.Classes.Say.OnClientEvent:Connect(function(msg, from, inclass) -- I hope this works... - Toby
    for i = 1, #inclass do
        if inclass[i] == game.Players.LocalPlayer.Name then
            local gui = game.ReplicatedStorage.InClass:Clone()
            gui.Frame.Message.Text = msg
            gui.Frame.From.Text = from
            local localplayerName = game.Players.LocalPlayer.Name
            gui.Parent = game.Players:FindFirstChild(localplayerName).PlayerGui
            wait(3)
            gui:Destroy()
        end
    end
end)

Thanks for reading this. - Toby

Answer this question