This error suggests there's a syntax issue in your script, likely a missing comma in the configuration table. Here's a corrected version that should resolve the syntax error:
-------------------------------------------------------------------
-- Fruit Spawner Script
-------------------------------------------------------------------
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
-- Add the comma here! This was likely the issue
RotationOffset = CFrame.Angles(-math.pi/2, 0, 0)
}
-------------------------------------------------------------------
local appleTemplate = ServerStorage:WaitForChild(CONFIG.AppleName)
local startPart = workspace:WaitForChild(CONFIG.StartPartName)
local endPart = workspace:WaitForChild(CONFIG.EndPartName)
local function setCFrame(object, cf)
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
while true do
local apple = appleTemplate:Clone()
apple.Parent = workspace
setCFrame(apple, startPart.CFrame)
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
local tween = TweenService:Create(
tweenTarget,
tweenInfo,
{CFrame = endPart.CFrame * CONFIG.RotationOffset}
)
tween:Play()
tween.Completed:Wait()
apple:Destroy()
wait(CONFIG.RespawnDelay)
end
The key fix is adding a comma after the RespawnDelay value in the CONFIG table. In Lua, when defining a table with multiple key-value pairs, you need a comma between each element.
Make sure:
- The script is in ServerScriptService
- You have a part named "StartPart" in Workspace
- You have a part named "EndPart" in Workspace
- Your Apple model/part is in ServerStorage
If you're still having issues, could you share:
- The exact error message
- The contents of your ServerStorage
- The parts in your Workspace