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

How to make a buy model script work?

Asked by 9 years ago

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

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 STICKYBUN10 19 — 9y
0
No wait I did have to add a function to my script, anyway thanks it works now :) STICKYBUN10 19 — 9y

2 answers

Log in to vote
1
Answered by
woodengop 1134 Moderation Voter
9 years ago

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
Ad
Log in to vote
5
Answered by
xuefei123 214 Moderation Voter
9 years ago

MakeJoints() Maybe

model:MakeJoints()

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

0
Okay thanks for the answer, although it was a very short answer, oh well I will try it STICKYBUN10 19 — 9y
0
Can you accept my answer plz? xuefei123 214 — 8y

Answer this question