I’m trying to make a basic coinflip experiment. I have the script and it works as simple as it’s so, but I want to make it where the player can enter the amount of bet they want as soon as they clicked on the coinflip part.
How should I figure this out?
Client sided script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local gamble = ReplicatedStorage:WaitForChild("50/50")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local part = game.Workspace["50/50"]
if player.leaderstats.Cash.Value >= 5 then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 5
local rng = math.random(1,2)
if rng == 2 then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 10
elseif rng == 1 then
so to get to the point, firstly you want to make your typical text button appear on the screen when they click on the detector, not fire the server first but as i mentioned, make a text button appear on the screen, add a set timer otherwise if they don’t input it in the limited duration, i guess do what you want
anyways, after the timer is up, check if there is an inputted number in the textbutton (check if its a string or int first just incase the script errors because its actually letters and not numbers), run an if statement where it has to be equal or lesser than what they have, make sure to clamp it on a minimum of 5 to prevent stuff where they get endless cash for loopholing by inputting a negative number instead unless they do accidentally get rng (2) which in mathematical terms, would give a negative form (positive basically) of the negative wager so that’s that
and another thing, just make sure that there is a debounce and that the gui disappears after they input it (except if you dont input a timer in the first place) so it does prevent some other issues from coming up, then you finally fire the server with the saved number of what they inputted and do your own thing
Sorry, but can you give me an example? I don’t really understand how I’d be able to pull that off. I do think of an idea where if the player enters the amount of value they want in the chat, it would be placed on bet and the coinflip script would start if they press it, but I don’t know how.