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

Script not kicking players? Player is userdata value?

Asked by
Aimarekin 345 Moderation Voter
7 years ago

Hi! I've been scripting for my game, and I wanted to make a system that sets an ID for every player in-game. I mean, there is one ID per player a server can held, for example i've got a boolvalue "ID1". When a user enetrs and the ID1 is false (Wich means it's unoccupied), the boolvalue becomes true and some other values inside are filled with the player's information, as well as in the player's character and player there is an objectvalue that takes you to the ID boolvalue it's occuping. Anyway, I wanted to kick the player if all the IDs are taken. So i made an else... (I know it's useless to kick the player, because ROBLOX will do it if the server is full, but idk, maybe the IDs have broke and they are all true but really there is nobody in the server xd)

 local playerservice = game:GetService("Players")

function SetPlayerID (player)
    player.CharacterAdded:Wait ()

    if script.Parent.ID1.Value == false then
        script.Parent.ID1.Value = true
        script.Parent.ID1.PlayerHumanoid.Value = player.Character.Humanoid
        script.Parent.ID1.PlayerPlayer.Value = player
        player.Character.IDobject.Value = script.Parent.ID1
        player.PlayerScripts.IDobject.Value = script.Parent.ID1
    else
        print ("Error while setting ID for ".. player)
        player:Kick ("There has been an error. Server may be full, please try again on another server. If this repeats, please send a bug report. ERROR CODE: IDSETNOTFOUND")
    end
end

playerservice.PlayerAdded:connect (SetPlayerID)

Everything is ran properly, all variables all set and everything, but if I test the game in a local server with 2 players, the script returns an error in the output and player2 isn't kicked at all...

Workspace.Player_InfoService.SetID:14: attempt to concatenate local 'player' (a userdata value)

I searched about userdatas on the wiki, but I didn't get why it was related to this. Anybody help?

0
Why is there no answer?? AizakkuZ 226 — 5y

1 answer

Log in to vote
1
Answered by
AizakkuZ 226 Moderation Voter
5 years ago

lool to fix this all u have to do is

print ("Error while setting ID for ", player)
0
loool actually print ("Error while setting ID for "..player.Name) im sorry i was too stupid before ;( AizakkuZ 226 — 5y
0
It's been some time since I asked this and I've gotten better now, but thanks for the answer lol Aimarekin 345 — 2y
Ad

Answer this question