its rotated bellow rotate it up
- User
its rotated bellow rotate it up
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
its rotated bellow rotate it up
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Below is an updated version of the spawner script that applies an extra rotation so that your spawned object is rotated "upright." In this example, we assume the Apple is rotated incorrectly when spawned at the StartPart. To correct this, we add a rotation offset using CFrame.Angles.
If you need a different rotation, simply adjust the angle values (in radians) below.
-------------------------------------------------------------------
-- Apple Spawner (with upward rotation fix)
-- Place this Script in ServerScriptService
-------------------------------------------------------------------
--// Services
local TweenService = game:GetService("TweenService")
local ServerStorage = game:GetService("ServerStorage")
--// Config -------------------------------------------------------
local CONFIG = {
AppleName = "Apple", -- name of your model/part in ServerStorage
StartPartName = "StartPart", -- name of the spawn point in workspace
EndPartName = "EndPart", -- name of the destination in workspace
TravelTime = 5, -- seconds for the Apple to move to EndPart
RespawnDelay = 3 -- pause between spawns
-- Rotation correction in radians (change these to adjust the orientation)
-- Here, the Apple is rotated -90° on the X-axis to face upward.
RotationOffset = CFrame.Angles(-math.pi/2, 0, 0)
}
-------------------------------------------------------------------
--// References
local appleTemplate = ServerStorage:WaitForChild(CONFIG.AppleName)
local startPart = workspace:WaitForChild(CONFIG.StartPartName)
local endPart = workspace:WaitForChild(CONFIG.EndPartName)
--// Helper: Applies a CFrame (with optional rotation offset) to a part or model
local function setCFrame(object, cf)
-- Apply rotation offset for an upright orientation
local newCF = cf * CONFIG.RotationOffset
if object:IsA("Model") then
if not object.PrimaryPart then
warn(object.Name .. " has no PrimaryPart!")
return
end
object:SetPrimaryPartCFrame(newCF)
else
object.CFrame = newCF
end
end
--// Main loop ----------------------------------------------------
while true do
----------------------------------------------------------------
-- 1) Spawn
----------------------------------------------------------------
local apple = appleTemplate:Clone()
apple.Parent = workspace
-- Use setCFrame with the rotation correction applied
setCFrame(apple, startPart.CFrame)
----------------------------------------------------------------
-- 2) Move (tween) to EndPart
----------------------------------------------------------------
local tweenInfo = TweenInfo.new(
CONFIG.TravelTime,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut
)
local tweenTarget
if apple:IsA("Model") then
tweenTarget = apple.PrimaryPart
else
tweenTarget = apple
end
-- Tween the Apple to the EndPart normally (if you need rotation during tween,
-- you can modify the target CFrame similarly)
local tween = TweenService:Create(
tweenTarget,
tweenInfo,
{CFrame = endPart.CFrame * CONFIG.RotationOffset}
)
tween:Play()
tween.Completed:Wait()
----------------------------------------------------------------
-- 3) Destroy & wait
----------------------------------------------------------------
apple:Destroy()
wait(CONFIG.RespawnDelay)
end
RotationOffset:
The RotationOffset key in the CONFIG table is set to CFrame.Angles(-math.pi/2, 0, 0). This rotates the spawned object by -90° about the X-axis. Adjust these values if your Apple needs a different rotation.
setCFrame Helper Function:
The helper multiplies the incoming CFrame (from StartPart) by the RotationOffset before applying it to your Apple. This ensures that the Apple is rotated correctly when it spawns.
Tweening With Rotation:
The tween target for the end position also uses the rotation offset to maintain consistency during the Apple’s journey.
Changing the Rotation:
If your Apple needs to be rotated differently, change the values in CFrame.Angles() accordingly. For example, to rotate by 90° on the Y-axis, you could use:
RotationOffset = CFrame.Angles(0, math.pi/2, 0)
Other Tweaks:
Modify TravelTime and RespawnDelay as needed to fine-tune your game’s pacing.
Test your game by hitting Play in Roblox Studio. The Apple should now spawn at StartPart with the corrected upward orientation, move toward EndPart, and then disappear before spawning again. Enjoy developing your game!