#Car doesn't spawn in right position

1 messages · Page 1 of 1 (latest)

signal valley
#

Could anyone help me with this? The car spawns, despawns and drives fine but it doesnt spawn next to me, rather it spawns in some fixed position

local re = game:GetService("ReplicatedStorage"):WaitForChild("CarCheck")

re.OnServerEvent:Connect(function(plr, car)
    local n = "Car-"..plr.Name
    local c = game.Workspace:FindFirstChild(n)
    
    if c then
        c:Destroy()
    end
    
    local s = game:GetService("ReplicatedStorage").Cars:FindFirstChild(car)
    if s then
        local f = s:Clone()
        f.Name = "Car-"..plr.Name
        f.Parent = workspace
        
        local l = plr.Character.HumanoidRootPart.Position
        f.Position = l
    elseif s == nil and car == "Ball" then
        local s = game:GetService("ReplicatedStorage").Cars:FindFirstChild("Ball")
        local f = s:Clone()
        f.Name = "Car-"..plr.Name
        f.Parent = workspace
        
        local l = plr.Character.HumanoidRootPart.Position
        f.Position = l
    end
end)
manic pond
#

yeah that's it's position

signal valley
manic pond
signal valley
#

Yes..?

manic pond
signal valley
#

Yes..??? 😭

manic pond
#

that's where it was before you put it in the replicatedstorage

signal valley
#

should the position change to the player's

#

on the clone

vale torrent
#

your code is hard to read because you don’t use variable names but that seems to be the issue i think

#

it could just be an issue with the car spawning exactly where it’s placed in serverstorage tho

signal valley
#

sorry im new to cframe, could you tell me how i would get that? would it be like ...RootPoint.CFrame.Position?

signal valley
vale torrent
#

cframe is the entire position

vale torrent
signal valley
#

ohh cool

vale torrent
#

if the car spawns in the same spot every time

#

then it’s probably not changing the cframe correctly

signal valley
#

yeah its still spawning in that same spot

vale torrent
signal valley
#

CFrame is not a valid member of Model "Workspace.Car-DoggeBoyz"

vale torrent
#

oh

#

you need to do the car.PrimaryPart

#

it’s automatically detected as long as the car has a set primarypart

signal valley
#

So i just move that? Originally i tried to move just the DriveSeat and it did work but it only moved the seat

vale torrent
#

cframe moves the model

#

so it’s fine

#

position doesn’t iirc

signal valley
#

so do i do ...Car.PrimaryPart.CFrame?

vale torrent
#

just test code and read errors until it works

#

learn the basics of luau before trying to code something

#

and name your variables better instead of just having a random letter

signal valley
#

i do lmao but im lazy for this script

rustic depotBOT
#

studio** You are now Level 7! **studio

signal valley
#

No errors, just moves the driveseat

rustic depotBOT
#

studio** You are now Level 10! **studio