Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Problems with Spawn car and deleting the old?

Hello everyone, I'm creating a spawn car, when they click on a button, they generate a car and erase the old ones but it don´t work can help me please i Need this

normal script Located in a part on Workspace it´s a BillboardGui

script.Parent.MouseButton1Click:connect(function(GetCar)
local plyr = game.Players.LocalPlayer
		Mod = game.ServerStorage.DodgeChallenger     
		clone = Mod:clone()
		clone.Parent = workspace
		clone:MakeJoints()
	if game.Workspace.DodgeChallenger.CurrentOwner.Value == plyr.Name then
		clone:Destroy() 
	end
		clone.CurrentOwner.Value = plyr.Name
	
end)

please help me with this code i need it

1 answer

✓ Accepted answer
local m = game:GetService("ServerStorage").DodgeChallenger
local click = script.Parent

click.MouseClick:connect(function(p)
	local player = game.Players[p.Name]
	if player then
		local owner = workspace:FindFirstChild(player.Name.."'s DodgeChallenger")
		if owner then
			owner:Destroy()
		end
		local clone = m:Clone()
		clone.Parent = workspace
		clone:MakeJoints()
		clone.Name = player.Name.."'s DodgeChallenger"
	end
end)

Instead of using a value, just rename the model, then it will be easy to find the owner This script should work now, just put the script inside a ClickDetector and its finished

3 comments

0

Sheesh, he is asking for a Gui script, not a ClickDetector.

0

lol he can change it though

0

no thanks it works i adapted it

This discussion is preserved as it was. New answers, comments, and votes are closed.