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

Problem with cloning car script?

Asked by 10 years ago

I want it so that when a Player wears a T-Shirt, they can purchase a VIP Vehicle, but there is an error on the script, and I do not know how to fix it. I will highlight it with a * . It is found near the bottom.

factory = script.Parent.Parent.Parent
local ting = 0
Upgradecost = script.Parent.Parent.Value.Value

local shirt = "http://www.roblox.com/asset/?id=155816530" --Original: 84744367

function onTouched(hit)
    if ting == 0 then
    ting = 1

   local h = hit.Parent:FindFirstChild("Humanoid")
       check = hit.Parent:FindFirstChild("Humanoid")

      local user = game.Players:GetPlayerFromCharacter(hit.Parent) 
      local stats = user:findFirstChild("leaderstats")
        local space = user:findFirstChild("Vehicles")


         if hit.Parent:FindFirstChild("Shirt Graphic").Graphic == shirt then

                local cash = stats:findFirstChild("Money")


                     if cash.Value > (Upgradecost-1) then

                 if space.Value == 0 then
                     space.Value = 1
                    cash.Value = cash.Value - Upgradecost
                script.Parent.Parent.Pad1.CanCollide = false
                script.Parent.Parent.Pad2.CanCollide = false
                     machine = factory.Stuff.Model23.Value:Clone() --Edit This!!
                    machine.Parent = h
                     machine:MakeJoints()
                msg = Instance.new("Message")
                 msg.Parent = user:findFirstChild("PlayerGui")
                  msg.Text = "VIP Vehicle Purchased! Please collect it from around the back."
                script.Parent.BrickColor = BrickColor.new("Black")
                script.Parent.Transparency = 0.95
                wait(1.5)
                script.Parent.Parent.Pad1.CanCollide = false
                script.Parent.Parent.Pad2.CanCollide = false
                script.Parent.Transparency = 0.9
                wait(1.5)
                script.Parent.Transparency = 0.85
                wait(1.5)
                script.Parent.Transparency = 0.8
                wait(0.5)
                  msg:remove()
                wait(1)
                script.Parent.Transparency = 0.75
                wait(1.5)
                script.Parent.Transparency = 0.7
                wait(1.5)
                script.Parent.Transparency = 0.65
                wait(1.5)
                script.Parent.Transparency = 0.6
                wait(1.5)
                script.Parent.Transparency = 0.55
                wait(1.5)
                script.Parent.Transparency = 0.5
                wait(1.5)
                script.Parent.Transparency = 0.45
                wait(1.5)
                script.Parent.Transparency = 0.4
                wait(1.5)
                script.Parent.Transparency = 0.35
                wait(1.5)
                script.Parent.Transparency = 0.3
                wait(1.5)
                script.Parent.Transparency = 0.25
                wait(1.5)
                script.Parent.Transparency = 0.2
                wait(1.5)
                script.Parent.Transparency = 0.15
                wait(1.5)
                script.Parent.Transparency = 0.1
                wait(1.5)
                script.Parent.Transparency = 0.05
                wait(1.5)
                script.Parent.Transparency = 0
                wait(1.5)
                script.Parent.BrickColor = BrickColor.new("Royal purple")

                     else
                msg = Instance.new("Message")
                 msg.Parent = user:findFirstChild("PlayerGui")
                  msg.Text = "You already own a vehicle."
                  wait(2)
                  msg:remove()
                     end

                     else
                msg = Instance.new("Message")
                 msg.Parent = user:findFirstChild("PlayerGui")
                  msg.Text = "You do not have enough money."
                  wait(2)
                  msg:remove()
                     end

                end

    else
    msg = Instance.new("Message")
    msg.Parent = user:findFirstChild("PlayerGui")
    msg.Text = "This vehicle requires VIP."
     wait(2)
     msg:remove()
    end

    else *
    msg = Instance.new("Message")
    msg.Parent = user:findFirstChild("PlayerGui")
    msg.Text = "This vehicle requires VIP."
     wait(2)
     msg:remove()
    end
end


ting = 0
end
end

script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by 10 years ago

Try using elseif at the bottom and see if it works.

elseif
msg = Instance.new("Message")
msg.Parent = user:findFirstChild("PlayerGui")
msg.Text = "This vehicle requires VIP."
wait(2)
msg:remove()
end
end
ting = 0
end
end
script.Parent.Touched:connect(onTouched)

Ad

Answer this question