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

Int. Value. Making a Door! Please Help?

Im Making a door that locks behind its self for a period of time.. Im trying to do this using int. Value!

script.Parent.ClickDetector.MouseClick:connect(function()
	if game.Workspace.Value >= 10 then
		game.Workspace.Value = 11
	else
	script.Parent.Parent.Door1.Transparency = 1
	script.Parent.Parent.Part1.Transparency = 1
	wait(1)
	script.Parent.Parent.Door2.Transparency = 1
	script.Parent.Parent.Part2.Transparency = 1
	wait(2)
	script.Parent.Parent.Door2.Transparency = 0
	script.Parent.Parent.Part2.Transparency = 0
	wait(1)
	script.Parent.Parent.Door1.Transparency = 0
	script.Parent.Parent.Part1.Transparency = 0
	game.Workspace.Value = 11	
	
	
	end
end)

Out Put:

--Workspace.Model.Button.Script:2: attempt to compare number with userdata

2 answers

✓ Accepted answer

Assuming that "Value" is referencing to an IntValue object in the Workspace that's called "Value", you should be doing this:

script.Parent.ClickDetector.MouseClick:connect(function()
    if game.Workspace.Value.Value >= 10 then
        game.Workspace.Value.Value = 11
    else
    script.Parent.Parent.Door1.Transparency = 1
    script.Parent.Parent.Part1.Transparency = 1
    wait(1)
    script.Parent.Parent.Door2.Transparency = 1
    script.Parent.Parent.Part2.Transparency = 1
    wait(2)
    script.Parent.Parent.Door2.Transparency = 0
    script.Parent.Parent.Part2.Transparency = 0
    wait(1)
    script.Parent.Parent.Door1.Transparency = 0
    script.Parent.Parent.Part1.Transparency = 0
    game.Workspace.Value.Value = 11   
    end
end)

You need to be referencing the Value property of an IntValue object. That property is what holds the integer.

If value is an IntValue in Workspace, it would be this (line 2):

if game.Workspace.Value.Value >= 10 then 

There is no "Value" property of Workspace.

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