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

script receiving Arguments and parameters wrong using remote events. Help?

Asked by 6 years ago
Edited 6 years ago

I got this following local script:

script.Parent.MouseButton1Click:connect(function()
    local ThePlayerName = script.Parent.Parent:WaitForChild("PlayerNameHere").Text
    script.Parent.Parent.Parent.Parent:WaitForChild("TotalBans").Main.UnBanPlayer:FireServer(ThePlayerName)
    print(ThePlayerName.."'s the player name that got sent!")
end)

And other following one:

script:WaitForChild("UnBanPlayer").OnServerEvent:connect(function(PlayerName)
    local points = 0
    for i,t in pairs (BannedPeople) do
        points = points + 1
        if t == (PlayerName) then
            table.remove(BannedPeople,points)
            print(PlayerName.." successfully removed!")
        end
    end
    points = 0
    ---------
    advance = 0
    print(PlayerName.." Is the player name received!")

I keep getting this error: 15:52:49.478 - Players.wilsonsilva007.PlayerGui.AdminGui.Background.TotalBans.Main:37: attempt to concatenate local 'PlayerName' (a userdata value)

But when I changed the PlayerName to PlayerName.Name it just printed my username..

I just want the script to send a 'Name' and receive that 'Name'. Only that. And this is getting me annoyed..

With 'OnClientEvent' and 'FireClient' it worked well in studio but didn't work in game.. And I'm unsure what I'm doing wrong.

Help would be apreciated! Thank you very much for your attention!

P.S. I didn't pay much attention to Arguments and parameters so if this is a really stupid and dumb question I'm sorry. /:

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

The first parameter of the OnServerEvent event is the player who fired it. All other arguments go after.

RemoteEvent.OnServerEvent:Connect(function(player,PlayerName)
    -- player is the player that called the event.
    -- PlayerName is the argument that you put when you called it.
end

Whenever you use OnServerEvent on OnServerInvoke, add player as the first argument.

0
Fixed, and thanks for being so fast! wilsonsilva007 373 — 6y
Ad

Answer this question