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

Click Buy Brick Color Gui Isn't Working And Not Sure Why, Would You Please Help Me?

This isn't working and I'd like to know why. This script is supposed to function to where, when a gui is clicked, you buy color for a brick. I'm not sure what the problem is, please help me. Edit: Would someone please help?

local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local cash = Instance.new("IntValue")
moneyToGive = -60
print "line 5"
function onclick()
	if cash.Value < 60 then
		script.Sound2:Play()
	end
	if cash.Value >= 60 then
		cash.Value = cash.Value + moneyToGive
		script.Sound:Play()
		print "line 14"
		game.Workspace.Desperado.Body.BD.BrickColor = BrickColor.new("Storm blue")
		game.Workspace.Desperado.Body.TailG.BrickColor = BrickColor.new("Storm blue")
	end
end
script.Parent.MouseButton1Click:connect(onclick)

2 comments

0

Why are the leaderstats being created on the client

0

I don't know, I was confused when I was working on this. I don't know how to do it though.

1 answer

✓ Accepted answer

Problems: - how does this bold thing work?(edit: oh.) The leaderstats you were trying to create were not going into the player. Also, some minor bugs and you said something about when a GUI is clicked but used BrickColor. Try using Color3. And I have no idea what is going on with the adding -60 cash to a player but okay. And let me know if it doesn't work.

game.Players.PlayerAdded:Connect(function(Player)
	local leaderstats = Instance.new("Folder",Player)
	leaderstats.Name = "leaderstats"
	local Cash = Instance.new("IntValue")
	Cash.Name = "Cash"
	Cash.Value = 0
end)

moneyToGive = -60 -- moneyToGive -60 lol moneyToTake -60
print("Line 2")
local Player = game.Players.LocalPlayer
local cash = "Cash"
script.Parent.MouseButton1Click:Connect(function() -- MouseButton1Click only works for GUI buttons.
    if Player.leaderstats ~= nil then
		if Player.leaderstats[cash].Value < 60 then
        script.Sound2:Play()
    else
    if Player.leaderstats[cash].Value >= 60 then
        Player.leaderstats[cash].Value = Player.leaderstats[cash].Value + moneyToGive -- moneyToGive - 60? so if current cash i 100 then adding - 60 will ??? 40?
        script.Sound:Play()
        game.Workspace.Desperado.Body.BD.BrickColor = BrickColor.new("Storm blue")
        game.Workspace.Desperado.Body.TailG.BrickColor = BrickColor.new("Storm blue")
    		end
		end
	end
end)

3 comments

0

Thanks, I'll try it out and let you know!

0

Everything works, thanks very much!

0

Your welcome, friend.

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