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

What wrong with this script?

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

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

3 comments

0

*unanchor

0

Where do I put the unanchor?

0

Line 12: Clone.Anchored = false

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)

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