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

Can't pass a string through two RemoteEvents?

I have been attempting to move a value (the plr one) through two different RemoteEvents, but it won't work and will come out as nil. Any help?

script.Parent.MouseButton1Click:Connect(function(plr)
	local target = script.Parent.Parent.NewTeamPlayerBox.Text 
	
	for Index, Player in pairs(game.Players:GetChildren()) do 
		if Player.Name:lower() == target:lower() then 
			game.ReplicatedStorage.RemoteEvents.PartyInvite:FireServer(target, plr)
		end
	end
end)
game.ReplicatedStorage.RemoteEvents.PartyInvite.OnServerEvent:Connect(function(target, plr)
	game.ReplicatedStorage.RemoteEvents.PartyInviteTo:FireClient(target,plr)
end)
game.ReplicatedStorage.RemoteEvents.PartyInviteTo.OnClientEvent:Connect(function(target, plr)
	script.Parent.Enabled = true
	script.Parent.PartyInviteFrame.InviteText.Text = plr.." has invited you to join their party."
	script.Parent.PartyInviteFrame.Inviter.Value = plr
end)

1 answer

fireserver(target)
onserverevent(playerthatfiredtheevent, target) -- you dont need plr bc the first parameter on onserverevent is always the player what fired it. 

from your script you are saying that 'target' is the person that fired it, 'plr' is the target so when you do fireclient, you are sending yourself nil

1 comment

0

You could also do the clicking on a server script and fire client without doing fireserver first. (would also prevent exploiters from spamming the text to the player every second)

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