Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
ziploz 7
8 years ago
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

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

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.
0
Thank you it works :D, i appreciate it ziploz 7 — 8y
0
:D User#11440 120 — 8y
Ad

Answer this question