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)
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)