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

How do you delete a car using a textbutton?

Asked by 3 years ago

I need help for this script, It doesnt let me delete the car if i already sat on the driveseat.

Script:

local P = script.Parent local player = script.Parent.Parent.Parent.Name--P.Parent.Parent local B = P.B B.MouseButton1Click:connect(function() if game.Workspace:FindFirstChild(player.."Car") then game.Workspace[player.."Car"]:Destroy() B.Text = "Mobil Dihapus" wait(2) B.Text = "Hapus Mobil" else game.Workspace[player.."Car"]:Destroy() B.Text = "Tidak Ada Mobil" wait(2) B.Text = "Hapus Mobil" end end)

0
Can you write it in a codeblock? It's kinda messy ItsMeBradon1257 0 — 3y
0
If this is a normal script then it won't work. If it's a localscript then it won't destroy anything. radiant_Light203 1166 — 3y
0
connect is deprecated, consider using Connect. ItsMeBradon1257 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Here is the code organised if anyone needs it (including me hehe):

local P = script.Parent
local player = script.Parent.Parent.Parent.Name
local B = P.B

B.MouseButton1Click:connect(function()
    if game.Workspace:FindFirstChild(player.."Car") then
        game.Workspace[player.."Car"]:Destroy()
        B.Text = "Mobil Dihapus" -- "Car Deleted"
        wait(2)
        B.Text = "Hapus Mobil" -- "Delete Car"
    else
        game.Workspace[player.."Car"]:Destroy()
        B.Text = "Tidak Ada Mobil" -- "No Car Found"
        wait(2)
        B.Text = "Hapus Mobil" -- "Delete Car"
    end
end)

And the language is in Indonesia, hooray.

0
Anyways the script won't work. ItsMeBradon1257 0 — 3y
0
Ikr its indonesian policemanph -2 — 3y
0
Where do you put this script? In the car? ItsMeBradon1257 0 — 3y
Ad

Answer this question