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

Can't pass a string through two RemoteEvents?

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
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

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) BulletproofVast 1033 — 3y
Ad

Answer this question