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

Remote Event dont fire Warn?

I made this script for a testing "Meeting" game but when i tested it wont get to change, these are my scripts:

Textbutton local script to start remote:

local WarnEVENT = game.ReplicatedStorage.Events.Warn

script.Parent.MouseButton1Click:Connect(function()
	local String = script.Parent.Parent.TextString.Text
	local String2 = "The hoster sayed: "
	local Write = string.format(String2, String)
	
	WarnEVENT:FireServer(Write, "ChangeWarn")
	print("Host Try to change Warn!")
end)

Serverscriptservice script to fireAllclients:

local WarnEVENT = game.ReplicatedStorage.Events.Warn

WarnEVENT.OnServerEvent:Connect(function(Write, Request)
	if Request == "ChangeWarn" then
		WarnEVENT:FireAllClients(Write)
		print("Changing for All players")
	else
		return
	end
end)

localscript inside the text to put warn:

local WarnEVENT = game.ReplicatedStorage.Events.Warn

WarnEVENT.OnClientEvent:Connect(function(Write)
	script.Parent.Text = Write
end)

If someone know's why not working please help!

1 answer

First argument on OnServerEvent:connect is always player that fired the event followed by the arguments you sent. In this case, function(Write, Request) turns into function(Player, Write, Request) Serverscriptservice script to fireAllclients:

local WarnEVENT = game.ReplicatedStorage.Events.Warn

WarnEVENT.OnServerEvent:Connect(function(Player, Write, Request)
    if Request == "ChangeWarn" then
        WarnEVENT:FireAllClients(Write)
        print("Changing for All players")
    else
        return
    end
end)

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