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

How to make a buy model script work?

Okay so I have been trying to make this car model I have made work as a buy able model to get for real money. The car is called the Tesla, my only problem is when I buy the model it spawns broken and out of shape. please help. Here is the script:

-------------------------------------------------------------------------------------------------------------------------

model = script.Parent.Parent.Parent.Tesla --Item name
Upgradecost = 1000  --Change cost to upgrade
------------------------------------------------------------------------------------------------------------------------- 

upgradeStuff = model:clone(Upgrader1)--
										

model:remove() --remove the ingame model. We saved a clone for later.

local ting = 0 --debouncer

function onTouched(hit)
	if ting == 0 then --check for debounce
	ting = 1 --activate debounce 
	check = hit.Parent:FindFirstChild("Humanoid") --try to find the human that touched the button

	if check ~= nil then --if toucher is a human then to following
		local user = game.Players:GetPlayerFromCharacter(hit.Parent) --get player from touching human
		local stats = user:findFirstChild("leaderstats") --Find moneyholder

		if stats ~= nil then --If moneyholder exists then
			local cash = stats:findFirstChild("Money") --Get money
			if cash.Value > (Upgradecost-1) then --If there is enough money then

				cash.Value = cash.Value - Upgradecost --remove cash
				upgradeStuff.Parent = script.Parent.Parent.Parent --put the upgrade into the game
				script.Parent.Parent:remove() -- remove the upgrade button (in case of one-upgrade only)

			end
		end
	end

	ting = 0 --remove debounce
	end
end

script.Parent.Touched:connect(onTouched) --start checking for touchers

Here are the links for proof:

C:\Users\Solrac\Documents\ROBLOX\Game Stuff\Astura with buy model button at start.png

C:\Users\Solrac\Documents\ROBLOX\Game Stuff\Astura afterwards (after bought using money).PNG

2 comments

0

Okay I think it was because I forgot to weld the car parts ( I only grouped them ) well thanks anyway and I will accept both answers

0

No wait I did have to add a function to my script, anyway thanks it works now :)

2 answers

✓ Accepted answer

You can use the MakeJoints Method, Now to add it to your script.

--> line 27-33
 upgradeStuff.Parent = script.Parent.Parent.Parent --put the upgrade into the game
upgrade:MakeJoints()
script.Parent.Parent:remove() -- remove the upgrade button (in case of one-upgrade only)
end
end
end

MakeJoints() Maybe

model:MakeJoints()

Instead of clone() may work, or anchor the things and weld them possibly

2 comments

0

Okay thanks for the answer, although it was a very short answer, oh well I will try it

0

Can you accept my answer plz?

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