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

What wrong with this script?

Asked by 10 years ago

I'm trying to make it to where you buy the car and have it spawn at its corrdinates with no problems. However there are 2 problems.

1) The car is anchored and I don't know how to unanchor it through scripting.

2) The Cloned model falls apart. I try :MakeJoints() but some parts still fall apart

Any Help?

Script:

COC = game.Workspace["Nissan 240SX(Car)"]:GetChildren()

function OnTouched(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player then
            if player:FindFirstChild("leaderstats") then
                if player.leaderstats.Money.Value >= 68000 then
                    player.leaderstats.Money.Value = player.leaderstats.Money.Value - 68000
                    local Clone = game.Workspace["Nissan 240SX(Car)"]:Clone()
                    Clone.Parent = game.Workspace
                    Clone:MakeJoints()
                    Clone:MoveTo(Vector3.new(-27, 6.2, -877))
                end
            end
        end
    end
end

script.Parent.Touched:connect(OnTouched)

2 answers

Log in to vote
0
Answered by 10 years ago

You unachor it using Clone.Anchored = false. Hoped I helped!

0
*unanchor PyccknnXakep 1225 — 10y
0
Where do I put the unanchor? notes4u99 65 — 10y
0
Line 12: Clone.Anchored = false PyccknnXakep 1225 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Try using the MakeJoints() method before putting the clone into the Workspace, and don't for get to anchor!

COC = game.Workspace["Nissan 240SX(Car)"]:GetChildren()

function OnTouched(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player then
            if player:FindFirstChild("leaderstats") then
                if player.leaderstats.Money.Value >= 68000 then
                    player.leaderstats.Money.Value = player.leaderstats.Money.Value - 68000
                    local Clone = game.Workspace["Nissan 240SX(Car)"]:Clone()
                    Clone:MakeJoints()
                    Clone.Anchored = false                 
                    Clone.Parent = game.Workspace
                    Clone:MoveTo(Vector3.new(-27, 6.2, -877))
                end
            end
        end
    end
end

script.Parent.Touched:connect(OnTouched)

Answer this question