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

Error Comparing User Data Value to Number Value. How do I fix this?

You see, the flr.Value is an IntValue and I'm comparing it to the Number 2 and it isn't working. Here's the code.

flr = script.Parent.Parent.Parent.Floor
prm = script.Parent.Parent.Parent.PrimaryPart
script.Parent.OnServerEvent:Connect(function(WhichFloor)
	if WhichFloor > flr.Value then
		for v = 0,WhichFloor,1 do
			for i = 0,200,1 do
				script.Parent:SetPrimaryPartCFrame(CFrame.new(prm.Position.X,prm.Position.Y + 0.1,prm.Position.Z))
				wait(0.01)
			end
			flr.Value = flr.Value + 1
		end
	else
		for v = 0,WhichFloor,1 do
			for i = 0,200,1 do
				script.Parent:SetPrimaryPartCFrame(CFrame.new(prm.Position.X,prm.Position.Y - 0.1,prm.Position.Z))
				wait(0.01)
			end
			flr.Value = flr.Value - 1
		end
	end
end)

WhichFloor is 2 btw

1 comment

0

By The way, when I said print(flr.value) it spat out 0. So I'm really confused.

1 answer

This is a simple mistake OnServerEvent passes the player as the first argument meaning your script is comparing the player on line 4 if WhichFloor > flr.Value then

Add another paramater into the function for the player.

script.Parent.OnServerEvent:Connect(function(Plr, WhichFloor)

end)

I hope this helps.

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