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.
To adjust the orientation of the Apple as it spawns and moves, you can modify the script to set its initial CFrame (or rotation) to match the StartPart's, and optionally, adjust its orientation during the tween.
Here's an updated version of the script that includes a simple adjustment to ensure the Apple is oriented correctly as it moves:
-------------------------------------------------------------------
-- Apple Spawner v1
-- Put this Script in ServerScriptService
-------------------------------------------------------------------
--// Services
local TweenService = game:GetService("TweenService")
local ServerStorage = game:GetService("ServerStorage")
--// Config -------------------------------------------------------
local CONFIG = {
AppleName = "Apple", -- name of the model/part in ServerStorage
StartPartName = "StartPart", -- name of the starting marker in workspace
EndPartName = "EndPart", -- name of the destination marker in workspace
TravelTime = 5, -- seconds it takes to move to EndPart
RespawnDelay = 3, -- seconds to wait before the next spawn
-- Optional: adjust the initial orientation (CFrame) of the Apple
InitialOrientation = CFrame.Angles(math.rad(0), math.rad(0), math.rad(0)) -- X, Y, Z in degrees
}
-------------------------------------------------------------------
--// References
local appleTemplate = ServerStorage:WaitForChild(CONFIG.AppleName)
local startPart = workspace:WaitForChild(CONFIG.StartPartName)
local endPart = workspace:WaitForChild(CONFIG.EndPartName)
--// Helper: puts a model/part at a CFrame ------------------------
local function setCFrame(object, cf)
if object:IsA("Model") then
if not object.PrimaryPart then
warn(object.Name .. " has no PrimaryPart!")
return
end
object:SetPrimaryPartCFrame(cf)
else
object.CFrame = cf
end
end
--// Main loop ----------------------------------------------------
while true do
----------------------------------------------------------------
-- 1) Spawn
----------------------------------------------------------------
local apple = appleTemplate:Clone()
apple.Parent = workspace
-- Set initial CFrame with optional orientation adjustment
local initialCFrame = startPart.CFrame * CONFIG.InitialOrientation
setCFrame(apple, initialCFrame)
----------------------------------------------------------------
-- 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
-- To keep the Apple oriented correctly during the tween,
-- you can CFrame.lookAt() it towards the EndPart
local function updateOrientation()
if tweenTarget then
tweenTarget.CFrame = CFrame.lookAt(tweenTarget.CFrame.Position, endPart.CFrame.Position)
end
end
-- Optional: Continuously update the orientation during the tween
-- (Uncomment the spawn connection below to enable this)
-- game:GetService("RunService").RenderStepped:Connect(updateOrientation)
local tween = TweenService:Create(
tweenTarget,
tweenInfo,
{CFrame = endPart.CFrame}
)
tween:Play()
tween.Completed:Wait()
-- Stop updating orientation if enabled
-- (You'll need to store the connection and disconnect it; not shown here)
----------------------------------------------------------------
-- 3) Destroy & wait
----------------------------------------------------------------
apple:Destroy()
wait(CONFIG.RespawnDelay)
end
To rotate the Apple "up" as it spawns, you can adjust the InitialOrientation in the CONFIG table. For example, to rotate it 90 degrees around the X-axis (so it's "upright"), you can set:
InitialOrientation = CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
This will make the Apple spawn with its top pointing "up" relative to the world's coordinates, assuming the StartPart is oriented normally.
If you want the Apple to continuously face or be oriented towards the EndPart as it moves, you can uncomment the RenderStepped connection and implement the updateOrientation function properly. However, be aware that this might require additional handling to smoothly animate the orientation change.
Let me know if you need further adjustments or have other questions!