Move model in server storage with tweening service

I’m trying to make a model (small map that is a model) move using tweening service, while it is in server storage. So basically the player spawns at the lobby, map gets chosen from server storage, map spawns, player gets teleported to spawns on the map, round starts but the tweening service doesn’t move the map model when the round starts. Tweening service does move it in workspace fine but I need the tweening service to move the map model once it’s spawned in from server storage.

I’ve tried changing the 1st and 3rd line to locate the model in server storage but nothing happens.

The code that I’ve tried so far for the tweening service is this -

repeat wait() until game.ServerStorage:FindFirstChild(‘city’)
local MoveModel = game.ReplicatedStorage.MoveModel
local Model = game.ServerStorage:FindFirstChild(‘city’)

local tweenService = game:GetService(“TweenService”)
local tweenInfo = TweenInfo.new(
95, – Time to get to destination
Enum.EasingStyle.Sine, – EasingStyle
Enum.EasingDirection.InOut, – EasingDirection
0, – RepeatCount (when less than zero the tween will loop indefinitely)
false, – Reverses (tween will reverse once reaching it’s goal)
0 – DelayTime
)

–// …But don’t mess with anything below !
local function tweenModel(model, CF)
local CFrameValue = Instance.new(“CFrameValue”)
CFrameValue.Value = model:GetPrimaryPartCFrame()

CFrameValue:GetPropertyChangedSignal("Value"):connect(function()
	model:SetPrimaryPartCFrame(CFrameValue.Value)
end)

local tween = tweenService:Create(CFrameValue, tweenInfo, {Value = CF})
tween:Play()

tween.Completed:connect(function()
	CFrameValue:Destroy()
end)

end

MoveModel.OnClientEvent:Connect(function()
if Model:FindFirstChild(‘Ground’)then
Model.PrimaryPart = Model:FindFirstChild(‘Ground’)
tweenModel(Model,CFrame.new(0, 0.2, -3584.6))
end
end)

1 Like

any ideas from anyone on this?

This is hard to read dude, try fixing the code format first by putting them in two (```)

Remove the parenthesis.

It would be like this:

local code = "yes im on a code format"

print(code)

That’s maybe the reason why you are not getting some respond for the past hours. People are getting tired/lazy to read/fix your problem (Same as me).

1 Like

Fixed it so it’s easier to read.

repeat wait() until game.ServerStorage:FindFirstChild("city")
local MoveModel = game.ReplicatedStorage.MoveModel
local Model = game.ServerStorage:FindFirstChild("city")

local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
	95, 
	Enum.EasingStyle.Sine, 
	Enum.EasingDirection.InOut, 
	0, 
	false, 
	0 
)

local function tweenModel(model, CF)
	local CFrameValue = Instance.new("CFrameValue")
	CFrameValue.Value = model:GetPrimaryPartCFrame()

	CFrameValue:GetPropertyChangedSignal("Value"):connect(function()
		model:SetPrimaryPartCFrame(CFrameValue.Value)
	end)

	local tween = tweenService:Create(CFrameValue, tweenInfo, {Value = CF})
	tween:Play()

	tween.Completed:connect(function()
		CFrameValue:Destroy()
	end)
end

MoveModel.OnClientEvent:Connect(function()
	if Model:FindFirstChild("Ground")then
		Model.PrimaryPart = Model:FindFirstChild("Ground")
		tweenModel(Model,CFrame.new(0, 0.2, -3584.6))
	end
end)
2 Likes

Only server scripts can access ServerStorage, why is this?

OnClient is for localscripts only.

Yep, that’s why Im confused too.

Same as this:

I didn’t think that tweening an object while its not on the Workspace. (Correct me if im wrong and if its possible.)

Yes, you can move a model in ServerStorage.

https://gyazo.com/15e577baabd64c29110ceafc61f272b4

1 Like

Sorry if I misunderstood your goal, but why exactly would this be useful? Tweening something that is inside ServerStorage is unnecessary since it’s invisible to the player. If you need the map to be visible once the player spawns, you can either:

  • Tween it before/when the player spawns (don’t know your setup, so doesn’t necessarily have to work out)

  • Move it normally with the Primary part

  • Already have it moved inside of the server storage

One thing to note: You can’t easily tween models
It would also help if you told us what exactly is happening. Does it throw an error, or does it just do nothing?

1 Like