Later, I rescripted a train spawner called “SpawnTrainScript2”, but the ObjectValue doesn’t have the CFrame property.
Look at some script:
local plrEngine = {}
local spawnLocation = workspace.spawnLocation
local replicatedStorage = game.ReplicatedStorage
local spawnTrainEvent = replicatedStorage.SpawnTrainEvent
spawnTrainEvent.OnServerEvent:Connect(function(plr, engineAsset, sLocation)
if engineAsset then
if plrEngine[plr] then
plrEngine[plr]:Destroy()
end
local randomBerth = sLocation
local newEngine = engineAsset:Clone()
newEngine:PivotTo(randomBerth.CFrame + Vector3.new(0, 10, 0))
local char = plr.Character or plr.CharacterAdded:Wait()
local _, engineSize = newEngine:GetBoundingBox()
char:PivotTo(newEngine:GetPivot()*CFrame.new(engineSize.X / 2 + 5, 0, 0))
newEngine.Parent = workspace
plrEngine[plr] = newEngine
end
end)
LocalScript:
local p = script.Parent
local player = game.Players.LocalPlayer
local trainSpawnerGui = player.PlayerGui.TrainSpawnerGui
local replicatedStorage = game:GetService("ReplicatedStorage")
local thomas = replicatedStorage.TrainAssets.Locomotives.Steam:WaitForChild("Thomas")
local sLocationSelected = trainSpawnerGui.TrainSpawnerFrame:WaitForChild("SpawnLocationSelected").Value
local test1 = game.Workspace.spawnLocation:WaitForChild("Test1")
local locoListFrame = p.Parent.SteamLocoListFrame
local engineInfo = require(p.Parent.ModuleScript)
engineInfo.MakeEngineInfo(thomas, "Thomas", locoListFrame, sLocationSelected)
How do I fix the CFrame property instead of ObjectValue?
