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

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

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()

2 comments

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.

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')]

1 answer

✓ Accepted answer

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()

2 comments

1

Thank you, it works very well

0

np!

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