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

LocalPlayer's ID is the same, but still failing?[SOLVED]

Asked by
BloxRoxe 109
6 years ago
Edited 6 years ago

I am making an Imagebutton that when clicked on, it checks to see if your ID matches the localplayer's ID. if so, it will tell you that you cant battle yourself.

It keeps giving me the failed output. Anyone know the reason why? both "id" and "localplayerid" match when tested.

local id = script.Parent.Parent.PlayerID.Value
local text = script.Parent.Battletext
local localplayerid = game.Players.LocalPlayer.UserId

script.Parent.MouseButton1Click:connect(function()
    print(id)
    print(localplayerid)
    if id == localplayerid then
        print("cant battle yourself!")
    else
        print("failed")
    end
end)
0
Is the PlayerID value a StringValue? NumberValue? IntValue? awesomeipod 607 — 6y
0
String BloxRoxe 109 — 6y
0
I just changed it to IntValue, it's now solved. I tried using PlayerID to store other data, when I don't need it. BloxRoxe 109 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

The property UserId is a int64 and PlayerID.Value a StringValue, so they never going to be the same. Try to convert the UserId to a string, like this:

local id = script.Parent.Parent.PlayerID.Value
local text = script.Parent.Battletext
local localplayerid = game.Players.LocalPlayer.UserId

script.Parent.MouseButton1Click:connect(function()
    print(id)
    print(localplayerid)



    if id.__tostring() == localplayerid then



        print("cant battle yourself!")
    else
        print("failed")
    end
end)
0
thank you. BloxRoxe 109 — 6y
Ad

Answer this question