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