-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.
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)
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
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
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)
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.
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?