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

hello

before we get started,

-my script is local
-this is for my coinflip
-it helps a lot when i get full scripts\

as mentioned above, this is my coin flip script.

SCRIPT:

local Players = game:GetService("Players")
local status = script.Parent.Parent.Parent.Parent.Parent
local player = Players.LocalPlayer
local winorloose = script.Parent.Parent.Parent.Text
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
script.Parent.MouseButton1Click:Connect(function()
	local BetAmount = script.Parent.Parent.Text
	
	
	if tostring(cash.Value) <= BetAmount then
	
		local chance = math.random(1,100)
		
		
		if chance > 50 then
			script.Parent.Parent.Parent.Parent.Visible = true
			wait(2)
			if winorloose == "Heads" then status.Text = ("Heads, you WIN")
				BetAmount = BetAmount * 2
				cash.Value = cash.Value + BetAmount
			elseif winorloose == "Tails" then status.Text = ( "Tails, You Loose")
				cash.Value = cash.Value - BetAmount
			wait(1)
			script.Parent.Parent.Parent.Parent.Visible = true
				status.Text = "DOUBLE YOUR MONEY!"
				
				
				
				if chance <= 50 then
					script.Parent.Parent.Parent.Parent.Visible = true
					wait(2)
					if winorloose == "Heads" then status.Text = ("Heads, you Loose")
						cash.Value = cash.Value - BetAmount
					elseif winorloose == "Tails" then status.Text = ( "Tails, You WIN")
						BetAmount = BetAmount * 2
						cash.Value = cash.Value + BetAmount
						wait(1)
						script.Parent.Parent.Parent.Parent.Visible = true
						status.Text = "DOUBLE YOUR MONEY!"
						
						
						
		else status.Text = "Invalid amount or error"
			wait(4)
						status.Text = "DOUBLE YOUR MONEY!"
						
						
					end
				end
			end
		end
	end
end)

WHAT THE SCRIPT IS SUPPOSE TO DO
the player puts the amount in a text label, select heads or tails which changes the text, then presses start.

my script checks if the amount they put in is equal to or less than the amount they entered.
if it is, then disable all controls and get a random number 1-100
if its 49 or less then it is heads and if player chose heads then double amount they put in text label before it became invisible.
the opposite happens if they did not choose heads and take away the amount they put in then the banner says you loose.

(SAME APPLIES OTHER WAY AROUND IF 51 AND HIGHER)

HOWEVER, after reviewing the script i find no errors and nor does the game. when the player enters the amount and presses there choice (HEADS OR TAILS) then presses start nothing happens. no call stack, no error, nor warning nor anything.

if you can find it out i will be amazed!

THIS MAY HELP:



replace the if with elseif statement

alright i did that but im getting same affect.

edit: new script is this:

local Players = game:GetService("Players")
local status = script.Parent.Parent.Parent.Parent.Parent
local player = Players.LocalPlayer
local winorloose = script.Parent.Parent.Parent.Text
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
script.Parent.MouseButton1Click:Connect(function()
	local BetAmount = script.Parent.Parent.Text
	
	
	if tostring(cash.Value) <= BetAmount then
	
		local chance = math.random(1,100)
		
		
		if chance > 50 then
			script.Parent.Parent.Parent.Parent.Visible = false
			wait(2)
			if winorloose == "Heads" then status.Text = ("Heads, you WIN")
				BetAmount = BetAmount * 2
				cash.Value = cash.Value + BetAmount
			elseif winorloose == "Tails" then status.Text = ( "Tails, You Loose")
				cash.Value = cash.Value - BetAmount
			wait(1)
			script.Parent.Parent.Parent.Parent.Visible = true
				status.Text = "DOUBLE YOUR MONEY!"
				
				
				
				elseif chance <= 50 then
					script.Parent.Parent.Parent.Parent.Visible = false
					wait(2)
					if winorloose == "Heads" then status.Text = ("Heads, you Loose")
						cash.Value = cash.Value - BetAmount
					elseif winorloose == "Tails" then status.Text = ( "Tails, You WIN")
						BetAmount = BetAmount * 2
						cash.Value = cash.Value + BetAmount
						wait(1)
						script.Parent.Parent.Parent.Parent.Visible = true
						status.Text = "DOUBLE YOUR MONEY!"
						
						
						
		else status.Text = "Invalid amount or error"
			wait(4)
						status.Text = "DOUBLE YOUR MONEY!"
						
						
					end
				end
			end
		end
end)

ok, in the winnerloose variable remove the “.Text” but add that on every end of the winnerloose(here) = “Tails” or “Head”

ok so that doesnt work as well. heres new script:

local Players = game:GetService("Players")
local status = script.Parent.Parent.Parent.Parent.Parent
local player = Players.LocalPlayer
local winorloose = script.Parent.Parent.Parent
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
script.Parent.MouseButton1Click:Connect(function()
	local BetAmount = script.Parent.Parent.Text


	if tostring(cash.Value) <= BetAmount then

		local chance = math.random(1,100)


		if chance > 50 then
			script.Parent.Parent.Parent.Parent.Visible = false
			wait(2)
			if winorloose.Text == "Heads" then status.Text = ("Heads, you WIN")
				BetAmount = BetAmount * 2
				cash.Value = cash.Value + BetAmount
			elseif winorloose.Text == "Tails" then status.Text = ( "Tails, You Loose")
				cash.Value = cash.Value - BetAmount
				wait(1)
				script.Parent.Parent.Parent.Parent.Visible = true
				status.Text = "DOUBLE YOUR MONEY!"



			elseif chance <= 50 then
				script.Parent.Parent.Parent.Parent.Visible = false
				wait(2)
				if winorloose.Text == "Heads" then status.Text = ("Heads, you Loose")
					cash.Value = cash.Value - BetAmount
				elseif winorloose.Text == "Tails" then status.Text = ( "Tails, You WIN")
					BetAmount = BetAmount * 2
					cash.Value = cash.Value + BetAmount
					wait(1)
					script.Parent.Parent.Parent.Parent.Visible = true
					status.Text = "DOUBLE YOUR MONEY!"



				else status.Text = "Invalid amount or error"
					wait(4)
					status.Text = "DOUBLE YOUR MONEY!"


				end
			end
		end
	end
end)


the answer could be that i messed my variable locations up so i will try to mess with that. if you wana see as well i suggest looking at photos showing the workspace

i added another .Parent to winnorloose and still not working :frowning:

i want the whole hierarchy of the GUI, also why are you judging decisions based off winorloose’s text? that is very buggy and go use a bool value instead for true if it’s a head and tail is false vice versa

becuase its easier for me to just put a script inside the buttons that say heads or tale that change the text of the winnorloose label then the script look at that instead of doing 100x more

this can be still really buggy and that’s only like used for inputting manual codes, not to mention in most codes they aren’t made to be still able to input in with a proper capitalization

like i said post the whole hierarchy here

would it be better if i made a baseplate with the ui and scripts then gave u editor access?

just put the whole hierarchy here i don’t got time to login in

ok
startergui contains Coinflip (which is a screen gui.)
the screengui coinflip has a frame named coinflip and nothing else.

the frame contains:
Frame (Just decor behind heads/tails button)
Frame(decor that changes half screens color to black) Containing:

Text Label (decor giving players instructions)

Image Label (a screen where i will eventually turn into an animation) Containing:

Status (text telling current instruction) Containing:

Bet (the text that is heads or tales depending on if they chose the heads/tales button) Containing:

heads and tales button (With script that changes the bet label)
and
YouBet (the text the player can edit there amount they wana bet) Containing:

CashAmount(Text label with script displaying cash value) Containing:

Play(Button player pressed in order to start script)

playbutton script:

local Players = game:GetService("Players")
local status = script.Parent.Parent.Parent.Parent.Parent
local player = Players.LocalPlayer
local winorloose = script.Parent.Parent.Parent.Parent
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
script.Parent.MouseButton1Click:Connect(function()
	local BetAmount = script.Parent.Parent.Text


	if tostring(cash.Value) <= BetAmount then

		local chance = math.random(1,100)


		if chance > 50 then
			script.Parent.Parent.Parent.Parent.Visible = false
			wait(2)
			if winorloose.Text == "Heads" then status.Text = ("Heads, you WIN")
				BetAmount = BetAmount * 2
				cash.Value = cash.Value + BetAmount
			elseif winorloose.Text == "Tails" then status.Text = ( "Tails, You Loose")
				cash.Value = cash.Value - BetAmount
				wait(1)
				script.Parent.Parent.Parent.Parent.Visible = true
				status.Text = "DOUBLE YOUR MONEY!"



			elseif chance <= 50 then
				script.Parent.Parent.Parent.Parent.Visible = false
				wait(2)
				if winorloose.Text == "Heads" then status.Text = ("Heads, you Loose")
					cash.Value = cash.Value - BetAmount
				elseif winorloose.Text == "Tails" then status.Text = ( "Tails, You WIN")
					BetAmount = BetAmount * 2
					cash.Value = cash.Value + BetAmount
					wait(1)
					script.Parent.Parent.Parent.Parent.Visible = true
					status.Text = "DOUBLE YOUR MONEY!"



				else status.Text = "Invalid amount or error"
					wait(4)
					status.Text = "DOUBLE YOUR MONEY!"


				end
			end
		end
	end
end)


@reygenne1

mate the picture i need to see myself in case theres a mistake


image

why does the X button have a script (not local)

also remove these and replace it with something like “if coinside.Value = true then” --heads or “if coinside.Value = false then” --tails

by the way this shows entire thing with all folders open

edit: i dont know what concide is or means.
it may help if you can write the entire script using “concide” as well since i might get confused and it cause further issues.

“giving a lot of information clearly and in a few words; brief but comprehensive.”

ok fine i’ll rework on it then trial and error to fix it faster, hand me the model and i’ll recreate it from scratch to fix some major issues

ill duplicate my game and give u editor access

i only need the model since i’m already on studio

i dont know how to do that. plus if you have to change any ui it will be harder for you to share the new model to me.
edit: wait do i have to add u as a a friend to give u editor?

you just select on the coin gui then right click then do “save model” and turn on “can be used” something like that