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

How do you delete a car using a textbutton?

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)

3 comments

0

Can you write it in a codeblock? It's kinda messy

0

If this is a normal script then it won't work. If it's a localscript then it won't destroy anything.

0

connect is deprecated, consider using Connect.

1 answer

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.

3 comments

0

Anyways the script won't work.

0

Ikr its indonesian

0

Where do you put this script? In the car?

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