I’ve been trying to figure out why this userid hasn’t been working at all lately, and I hav not yet found a solution nor anything would answer this for me.
I’m confused on how this would be rejected as it’s a normal function, is there something wrong with Roblox or what?
Code:
local Settings = script.Parent:WaitForChild("Settings")
local PlayerAvailable = Settings:WaitForChild("AvailablePlayer")
Detector.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChildWhichIsA("Humanoid") then
local Humanoid = Hit.Parent:FindFirstChildWhichIsA("Humanoid")
if Humanoid.Health > 0 then
if game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent) then
local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
local UserId = Player.UserId
if PlayerAvailable.Value == UserId then
return warn("TRUE")
else
print(Hit.Parent.Name)
return warn("FALSE")
end
end
end
end
end)
local Settings = script.Parent:WaitForChild("Settings")
local PlayerAvailable = Settings:WaitForChild("AvailablePlayer")
local Detector = script.Parent
Detector.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChildWhichIsA("Humanoid") then
local Humanoid = Hit.Parent:FindFirstChildWhichIsA("Humanoid")
if Humanoid.Health > 0 then
if game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent) then
local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
local UserId = Player.UserId
PlayerAvailable.Value = UserId
if PlayerAvailable.Value == UserId then
return warn("TRUE")
else
print(Hit.Parent.Name)
return warn("FALSE")
end
end
end
end
end)
Realising my mistake, the reason why it must’ve been non-functioning is because I placed a number to a string value which caused it to break the statement as you cant compare strings to nums unless doing tonumber(StringValue) == num
Apologies as this must’ve been a waste of time, I will delete this post but sincerely please forgive me as I thought I made it a number value not a string value.
I should probably start checking properties and etc before assuming the code is broken.
No worries. I mean, if you really wanted to continue this on a StringValue you could with
if tonumber(PlayerAvailable.Value) == UserId then
But honestly there is no purpose in that considering that you have the issue solved now and there is really no advantage to having this as a stringValue rather than IntValue