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

My gui works buy my buying script and spawing not work just on studio wtf?

Asked by 7 years ago

Its working in the studio but not in the game? Wtf?!

The script i used :

local player = game.Players.LocalPlayer --Assuming the script is a localscript, you can shorten this.
local cost = 250

script.Parent.MouseButton1Click:connect(function()
local leaderstats = player:FindFirstChild("leaderstats") --You don't need nearly as many if statements as you had, since if the code results in error, it will stop running and can be recalled when the button is pressed again.
local money = leaderstats:FindFirstChild("Money")
if money.Value >= cost then
local spawncar = game.Lighting["BMWM3"]:clone()
spawncar.Parent = workspace
spawncar:MakeJoints() --Assuming you already have proper welds established in the car.
money.Value = money.Value - 250
script.Parent.Text = "Bought"
else
script.Parent.FontSize = 6
script.Parent.Text = "Not enough $"
end
end)
0
Use Localscript bossay8 8 — 7y
0
Or use TextLabel instead of TextBox bossay8 8 — 7y
0
Thanks! working! Amasha69 0 — 7y
0
Please refrain from using swears; it may hurt someone's feelings. :c TheeDeathCaster 2368 — 7y

Answer this question