Help with my Heads/Tails script not responding on start click

you will need cash scripts also though

actually… did you also check it so there aren’t any invisible UIs blocking the click button?

theres not invisible parts blocking it.
ill share the model but it wont have cash scripts

this can happen if it’s positioned like in the same region as an invisible ui but it has lesser ZIndex than the invisible ui which prevents it from being clicked

Coin Flip - Roblox here.

does it work?
’
edit: goodnight im going to bed. ill check for rewsponses tommorow

i managed to fix all of the rest, go do some of your parts

Why is the script on the client? Even changing the money is on the client… It won’t replicate to the server and other players.
Unless you plan to make a single player game that does not save player data, then you may do this.

Anyhow the post above has fixed your problem, I presume.

hey, something annoying with your script is that theres no start button and it runs off of only if they click heads or tales. so even if they put no money in they can bet. also since you didnt use my money scripts it cant tell if they cant afford the amount they put in or not

it was just a working concept, they can put the bet inside themselves

local imagehead = "http://www.roblox.com/asset/?id=2827513284"
local imagetail = "http://www.roblox.com/asset/?id=1024533374"

local guiframe = script.Parent
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local imagelabel = script.Parent:WaitForChild("ImageLabel")
local bet = imagelabel.Status:WaitForChild("Bet")
local tails = bet:WaitForChild("Tails")
local heads = bet:WaitForChild("Heads")
local ubet = bet:WaitForChild("YouBet")
local cs = bet:WaitForChild("coinSide")
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")

local cd = true

if tostring(cash.Value) <= tostring(ubet) then
function maingamble()
	local chance = math.random(1, 100)
	local function outcome(chance)
		if chance > 50 and cs.Value == "Heads" then
			imagelabel.Image = imagehead
			return true
		elseif chance <= 50 and cs.Value == "Tails" then
			imagelabel.Image = imagetail
			return true
		end
		return false
	end
	local result = outcome(chance)
	if result then
			print(result)
			cash.Value = cash.Value + tonumber(ubet)
		
	else
			print(result)
			cash.Value = cash.Value - tonumber(ubet)
	end
end
end 
heads.MouseButton1Click:Connect(function(plr)
	if cd == true then
		cd = false
		cs.Value = "Heads"
		bet.Text = tostring(cs.Value)
		maingamble()
		task.delay(3, function()
			imagelabel.Image = ""
			bet.Text = ""
			cd = true
		end)
	end
end)

tails.MouseButton1Click:Connect(function(plr)
	if cd == true then
		cd = false
		cs.Value = "Tails"
		bet.Text = tostring(cs.Value)
		maingamble()
		task.delay(3, function()
			imagelabel.Image = ""
			bet.Text = ""
			cd = true
		end)
	end
end)

error:
Players.SakDevRblx.PlayerGui.Coin Flip.coin flip.Frame.stuff:33: attempt to perform arithmetic (add) on number and nil -

your programming is terrible and insecure, you did not check if what’s written in the betted value is considered a number which if someone tries writing “sus” inside it, the code would error since you can’t do arithmetics with strings

you can fix this by using if typeof(ubet.Value) == "Number" then

not to mention, at the top of the first function you wrote a code line that will check if you have like lesser cash value than what you bet literally outside the function

1 Like

@reygenne1 i have identified the error lies in

if tostring(cash.Value) <= tostring(ubet) then

after removing everything and testing its been noted that after adding this part i havent been able to run the code,

i can sort of see your getting tired of me so ill just give you solution. ]

thank you for all the help
the amount of visual distress i have caused you makes me feel guilty about myself since you dont deserve it and was very nice to help me for this long (Where most people would give up.) thank you

no i was just tired of the homework i saw right before my eyes and classes while i was discussing to you

im sorry :(. i wasnt trying to make it hard for you

1 Like

it’s fine also don’t discuss unnecessary and off topic things about personal interactions in here

Ok i was able to find the answer on my own