Alright here's the issue:

I've got a GUI that is given to a player upon walking into an area. This GUI gives the player the option to buy and then spawn in a vehicle of his/her own choosing. Once the player clicks a button the corresponding vehicle spawns at the designated area but it stops there - anchored. So I check out the model in the test server and find that all of the scripts inside of the model have disappeared!

I've tried singling out the problem but to no avail. Any help that you can give is most appreciated.

[LocalScript within the shop GUI]

wait(.1)
local Player = game.Players.LocalPlayer
local NoFunds = script.Parent.Extras.NoFunds
local PlayerCredits = game.Players.LocalPlayer.leaderstats.Credits
local Slot1 = script.Parent.ScrollingFrame.Slot1
local Slot2 = script.Parent.ScrollingFrame.Slot2
local Slot3 = script.Parent.ScrollingFrame.Slot3
local Close = script.Parent.Extras.CloseButton

local SpawnLocation = game.Workspace.HQVehicleSpawner.Position


Slot1.MouseButton1Click:connect(function ()
	local Cost = 0--Cost of item here

	if PlayerCredits.Value >= Cost then
	PlayerCredits.Value = PlayerCredits.Value - Cost
	local Vehicle = game.Lighting["Jeep"]:clone()--Name of vehicle
			Vehicle.Parent = game.Workspace
			Vehicle:makeJoints()
			Vehicle:MoveTo(SpawnLocation)--Location it spawns

	else
		NoFunds.Visible = true
		wait(3)
		NoFunds.Visible = false

		end
end)

Slot2.MouseButton1Click:connect(function ()
	local Cost = 0--Cost of item here

	if PlayerCredits.Value >= Cost then
	PlayerCredits.Value = PlayerCredits.Value - Cost
	local Vehicle = game.Lighting["TransportJeep"]:clone()--Name of vehicle
			Vehicle.Parent = game.Workspace
			Vehicle:makeJoints()
			Vehicle:MoveTo(SpawnLocation)--Location it spawns
			
	else
		NoFunds.Visible = true
		wait(3)
		NoFunds.Visible = false

		end
end)

Slot3.MouseButton1Click:connect(function ()
	local Cost = 0--Cost of item here

	if PlayerCredits.Value >= Cost then
	PlayerCredits.Value = PlayerCredits.Value - Cost
	local Vehicle = game.Lighting["JeepWrangler"]:clone()--Name of vehicle
			Vehicle.Parent = game.Workspace
			Vehicle:makeJoints()
			Vehicle:MoveTo(SpawnLocation)--Location it spawns

	else
		NoFunds.Visible = true
		wait(3)
		NoFunds.Visible = false

		end
end)

Close.MouseButton1Click:connect(function()
	script.Parent:Destroy()
end)

I've noticed that only scripts disappear when the vehicle is moved from Lighting to workspace. I've tried several different kinds of vehicles that have been scripted somewhat differently so I'm almost positive the problem isn't there. (but I really have no idea at this point)

Any other info you need, I'll try and provide, Thanks!

6 comments

0

Try disabling the scripts inside of the car (setting their Disabled property to true) and see if the scripts persist. Also, you're cloning from a LocalScript so I'm not sure how exactly that works.

0

Okay, I tried with the scripts in the vehicle disabled and the same problem occurred. Disabling the scripts had no affect.

0

possible make joints solutio?

0

i'd print the scripts od the clone and see if they are nil

0

I went ahead and tried moving the object to work space and then clone and move it from there, but I still had the same problem

0

I think that the problem lies with the script being Local and not a regular script. Now the problem I have is accessing the player's leaderstats in just a regular script.