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

Script not working, Is there something wrong in this script? if then statement is not working.

playbutton = script.Parent
mainmenu = script.Parent.Parent
loadingscreen = script.Parent.Parent.Parent.loading

playbutton.Text = "Play"
local cam = workspace.CurrentCamera

function onClicked()
	while true do
	loadingscreen.Position = loadingscreen.Position-UDim2.new(0.03,0,0,0)
	wait()
	end
end

if loadingscreen.Postion(0,0,0,0) == true then
	cam.CameraType = "Custom"
end

playbutton.MouseButton1Down:connect(onClicked)

Is there something wrong in this script, it doesnt works.

1 answer

✓ Accepted answer

Just use the Tween function. Here's a link to more info about it.

local cam = workspace.CurrentCamera
local playbutton = script.Parent
local mainmenu = playbutton.Parent
local loadingscreen = mainmenu.Parent:WaitForChild("loading")
-- ^^ added WaitForChild

playbutton.Text = "Play"

function onClicked()
	loadingscreen:TweenPosition(UDim2.new(),"In","Linear",2)
	wait(2)
	cam.CameraType = "Custom"
end

playbutton.MouseButton1Down:Connect(onClicked)
This should work. If it doesn't, message me the error down below.

Also, even if you did your if statement correctly it wouldn't have worked because the if statement only runs once. The correct way of writing your particular if statement it written below.

if loadingscreen.Position == UDim2.new(0,0,0,0) then
	cam.CameraType = "Custom"
end

-->or 

if loadingscreen.Position == UDim2.new() then
	cam.CameraType = "Custom"
end
You also spelled Position wrong

Good Luck!

If I helped, please don't forget to accept my answer.

2 comments

0

Thank you it works :D, i appreciate it

0

:D

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