****so i am trying to make this car dealership where if you click on a block thats infront of a car, a menu pops up (that works, here is a screenshot: https://imgur.com/NjUaJaT) with some info and a picture of the car. but i tried different types of scripts for the "purchase button" and none work. (i got this from another post because i am too dumb for this)
this is the one i have right now:
01 player = script.Parent.Parent.Parent.Parent.Parent
02 cost = 5000
03
04 script.Parent.MouseButton1Click:connect(function()
05 leaderstats = player:FindFirstChild("leaderstats")
06 if leaderstats then
07 money = leaderstats:FindFirstChild("Money")
08 if money then
09 if money.Value >= cost then
10 spawncar = game.Lighting:FindFirstChild("CiviCar"):clone() --Use FindFirstChild or WaitForChild instead.
11 local weld = Instance.new("Weld", spawncar.Seat) --Change this to any part in the car with a unique name. If your car already has welds, remove this line!
12 spawncar.Parent = workspace
13 spawncar:MakeJoints() --You need welds to actually use :MakeJoints(). MakeJoints is a function! Use ":" instead of "." like as if it's a property!
14 player.leaderstats.Money.Value = player.leaderstats.Money.Value - 5000
15 script.Parent.Text = "Bought"
16 else
17 script.Parent.FontSize = 14
18 script.Parent.Text = "Not enough $"
19 return
20 end
21 end
22 end
23 end)

1 comment
i am super noob at this stuff (like i said in the post) but it didn't work, and i have no clue if i have to add the localscript to the textbutton or not. what i changed made more warnings. i will provide a screenshot in another answer if you need it