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

why wont my tweens work after cloning something client-sided?

Asked by
Kaput_0 44
4 years ago

so im trying to make a 3d title screen where random scenes load in, this one has a looping tween of something moving down repeatedly but as soon as I start it up, the cloning works correctly even capable of activating and deactivating each of the scripts but the scripts themselves wont work even though I'm not getting a single error, both script types are local

this is the script that clones the scene itself:

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer
local camera = workspace.CurrentCamera

local cam

function Cammove()
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CameraSubject = workspace.current.Backplate
    camera.CFrame = workspace.current:FindFirstChild(cam.Value).CFrame
end
function LightingChange()
    local Lighting = workspace.current.Configuration.Lighting

    game.Lighting.GlobalShadows = Lighting.GlobalShadows.Value
    game.Lighting.FogEnd = Lighting.FogEnd.Value
    game.Lighting.FogColor = Lighting.FogColor.Value
    game.Lighting.FogStart = Lighting.FogStart.Value
end



function scr1 ()
    local screen1 = game.ReplicatedStorage:WaitForChild("Screen1")
    local new = screen1:Clone()

    new.Parent = workspace
    new.Name = 'current'
    new.Backplate.LocalScript.Disabled = false
    new.Blocks.Move.Disabled = false
    cam = workspace.current.Configuration.Camera
    Cammove()
    LightingChange()
end

scr1()

and this is the script that starts the tween:

--d2 -206, -102, -249

local TweenService = game:GetService("TweenService")

local part = script.Parent

local info = TweenInfo.new(
    10,                         --length(seconds)
    Enum.EasingStyle.Linear,        --easing style
    Enum.EasingDirection.InOut, --easing direction
    999999999999,               --times repeated
    false,                      --reverse?
    0                           --delay(in seconds)
)

local Goal =
{
    Position = Vector3.new(-206, -102, -249)
}

local tween = TweenService:Create(part,info,Goal)

tween:Play()
0
have you made sure that the tween works? if it does, maybe it's because you're cloning a script? you could try putting the second script's code into the first script. Mayk728 855 — 4y
0
i have tested the scripts before putting them in replicated storage, im not entirly sure how to make a script within a script byond just [instance.New('Script')] Kaput_0 44 — 4y

1 answer

Log in to vote
0
Answered by
Mayk728 855 Moderation Voter
4 years ago

Instead of having another LocalScript, I've combined the code from the second script into this one.

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer
repeat wait() until workspace.CurrentCamera
local camera = workspace.CurrentCamera

local cam

function Cammove()
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CameraSubject = workspace.current.Backplate
    camera.CFrame = workspace.current:FindFirstChild(cam.Value).CFrame
end
function LightingChange()
    local Lighting = workspace.current.Configuration.Lighting

    game.Lighting.GlobalShadows = Lighting.GlobalShadows.Value
    game.Lighting.FogEnd = Lighting.FogEnd.Value
    game.Lighting.FogColor = Lighting.FogColor.Value
    game.Lighting.FogStart = Lighting.FogStart.Value
end

function scr1 ()
    local screen1 = game.ReplicatedStorage:WaitForChild("Screen1")
    local new = screen1:Clone()

    new.Name = 'current'
    new.Blocks.Move.Disabled = false
    new.Parent = workspace

    local part = new.Backplate
    local info = TweenInfo.new(
        10,                         --length(seconds)
        Enum.EasingStyle.Linear,        --easing style
        Enum.EasingDirection.InOut, --easing direction
        999999999999,               --times repeated
        false,                      --reverse?
        0                           --delay(in seconds)
    )
    local Goal = {
        Position = Vector3.new(-206, -102, -249)
    }
    local tween = TweenService:Create(part,info,Goal)
    tween:Play()

    cam = workspace.current.Configuration.Camera
    Cammove()
    LightingChange()
end

scr1()
1
Thank you, it works very well Kaput_0 44 — 4y
0
np! Mayk728 855 — 4y
Ad

Answer this question