Help with tweening script for piggy game

I am fairly new to scripting, how do you do that? Just by saying local function

Try this code. I added the camera code and declared it as a local function.

local mainMenuMap = workspace:WaitForChild("MainMenuMap")
local tweenService = game:GetService("TweenService")
local btn = script.Parent

local currentCamera = game.Workspace.CurrentCamera
currentCamera.CameraType = Enum.CameraType.Scriptable

local function tweenCamera(pos,tweenTime)
     tweenService:Create(camera,TweenInfo.new(tweenTime,Enum.EasingStyle.Linear),{CFrame = pos.CFrame}):Play()
end

btn.MouseButton1Click:Connect(function()
    btn.Visible = false
    btn.Parent.Title.Visible = false

    tweenCamera(mainMenuMap.CameraPart2,1)
    wait(1)
    print("Reached Destination")
end)

idk if changing the function to local has any effect

1 Like

It’s just a good thing to learn and adjust to.

@Dev_Kittenz was correct. The script did not have any effect. Still broken.

Try changing MouseButton1Click to MouseButton1Down.

It is still broken. Does not seem to be changing every time we add a change :thinking:

Could you show a GIF or give a little bit more of an explanation of what is wrong with the script, I can’t see any fault in what has been provided to you unless I’m missing something.


@desinied

Is this supposed to be the “Penny” text?

Yes, its supposed to disappear when you press play.

Instead of this:

btn.Parent.Title.Visible = false

Use:

btn.Parent.TextLabel.Visible = false

Your script is looking for something named Title when in reality it was named TextLabel.

But its not called

It is called Title.

Your video has it named TextLabel :man_shrugging:

Sorry didnt see that. I will do that.

Alright that fixes that, but what about the actual topic of the post?

Have you play tested the game yet with the new fix?

Yes i have, the camera manip movement still wont work.

Can I see your output window? Just to make sure everything is correct.


the tweenservice:create just popped up. What can i do to fix it?