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

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

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)

3 comments

0

Is the PlayerID value a StringValue? NumberValue? IntValue?

0

String

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.

1 answer

✓ Accepted answer

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)

1 comment

0

thank you.

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