Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my car spawner that spawns a car only work in studio, but not in roblox in game?

Asked by 5 years ago

So i made a car spawner, that spawns a car if you click G. It works in studio. The car works, and the body doesnt fall apart, and i can drive it. But when i test it in game, the body falls apart, and i cant sit in the seat. The script is placed in the playergui/startergui. Can somebody help me? thanks!

script:

local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local name = plr.Name..("'s Car")
local debounce = false
uis.InputBegan:connect(function(key)
    if key.KeyCode == Enum.KeyCode.G then
for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren())do
    if v:IsA("Model") and v.Name == name then
    v:Destroy()

    end
    end
    end
end)
uis.InputEnded:connect(function(aey)
    wait()
    if aey.KeyCode == Enum.KeyCode.G then
         local car = plr.SelectedCar.Value:Clone()
        car.Parent = game.Players.LocalPlayer.Character
        car.Chassis.Base.Anchored = true
        car.Name = plr.Name..("'s Car")
        car:SetPrimaryPartCFrame(plr.Character.Head.CFrame * CFrame.new(0,0,-10))
        car:MakeJoints()
        wait(1)
        car.Chassis.Base.Anchored = false
    end
end)
0
do you have filtering enabled on? DatRainbowTee 49 — 5y
0
no ieatandisbaconhair 77 — 5y
0
FE is always on bc of the update even if u turn it off User#23365 30 — 5y
0
:connect() is decaperated use :Connect() and is ur script inside a local script or a server script User#23365 30 — 5y
View all comments (2 more)
0
localscript. also, i think connect() and Connect are the same thing, just with an capital C. ieatandisbaconhair 77 — 5y
0
also, i dont think fe is forced on even tho its off, i printed if filteringenabled is true or false and it said false ieatandisbaconhair 77 — 5y

Answer this question