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

Why is this script calling a boolean value?

I honestly have no idea but around the if statement, the script states it's attempted to call a boolean value.... anyone got any ideas why?

local frame = script.Parent.Parent:WaitForChild("Settings Frame")
--Made By MillerrIAm
---------------------------------------------------------
script.Parent.MouseButton1Click:Connect(function(click)
	if frame.Position == (UDim2.new(-1, 0, 0.481, 0)) then
		spawn(frame:TweenPosition(UDim2.new(0.001, 0, 0.481, 0), 'In', 'Linear', 0.5))
		script.Parent.Text = "CLOSE"
		script.Parent.TextColor3 = Color3.new(255,255,255)
		script.Parent.BackgroundColor3 = Color3.new(170,0,0)
	else 
		spawn(frame:TweenPosition(UDim2.new(-1, 0, 0.481, 0), 'In', 'Linear', 0.5))
		script.Parent.Text = "Settings"
		script.Parent.TextColor3 = Color3.new(0,0,0)
		script.Parent.BackgroundColor3 = Color3.new(255,255,255)
	end
end)

1 comment

0

I did try removing the extra parenthesis around the UDim2.new, it didn't fix it.

1 answer

✓ Accepted answer

Hello.

Problem:

You used spawn incorrectly. Spawn requires a function as an argument.

Solution:

Provide that function argument.

Fixed Code:

local frame = script.Parent.Parent:WaitForChild("Settings Frame")
--Made By MillerrIAm
---------------------------------------------------------
script.Parent.MouseButton1Click:Connect(function(click)
    if frame.Position == (UDim2.new(-1, 0, 0.481, 0)) then
        spawn(function() frame:TweenPosition(UDim2.new(0.001, 0, 0.481, 0), 'In', 'Linear', 0.5) end)
        script.Parent.Text = "CLOSE"
        script.Parent.TextColor3 = Color3.new(255,255,255)
        script.Parent.BackgroundColor3 = Color3.new(170,0,0)
    else 
        spawn(function() frame:TweenPosition(UDim2.new(-1, 0, 0.481, 0), 'In', 'Linear', 0.5) end)
        script.Parent.Text = "Settings"
        script.Parent.TextColor3 = Color3.new(0,0,0)
        script.Parent.BackgroundColor3 = Color3.new(255,255,255)
    end
end)

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