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

ObbyScript:20: attempt to get length of field 'TempConte stants' (a userdata value)?

I am scripting a game points system but it's not working and the error 12:02:10.739 - Workspace.CurrentObby.Obby1.ObbyScript:20: attempt to get length of field 'TempContestants' (a userdata value) shows. Here is my script

Obby = script.Parent
Functions = require(script.Functions)

Obby.End.Touched:connect(function (hit)
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if hum then
		local player = game.Players:GetPlayerFromCharacter(hum.Parent)
		if player then
			Functions:AddWinner(player)
		end
	end
end)

for i = Obby.ObbyInfo.Time.Value, 1, -1 do
	if i == 1 then
	     _G.Msg("The current game will end in".. tostring(i) .. "seconds")
	else  
	     _G.Msg("The current game will end in".. tostring(i) .. "seconds")
	end
	if #Obby.ObbyInfo.TempContestants <= 0 then
		break
	end
	wait(1)
end


Obby.ObbyInfo.Finished.Value = true

Please help asap :)

Thanks!

1 answer

✓ Accepted answer

I always make this mistake sometimes, but, I figure it out very quickly. It's simple to fix.

On line 20 of your code,

if #Obby.ObbyInfo.TempContestants <= 0 then

It checks for a value.

However, TempContestants is an object, not an integer. I am assuming it is an IntValue object, so you just need to add .Value on the end of the statement.

if #Obby.ObbyInfo.TempContestants.Value <= 0 then

1 comment

0

THANk you so much! I will try this, sorry for the late reply

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