So I am trying to make it that when a player doesn’t has enough cash to buy something then he will be notified that works just fine. But when a player has enough cash for it but he buys something else first, then his cash will be getting lowered. But when he first got enough cash for it it will say ‘This will cost 300$ are you sure?’ But he actually doesn’t haves enough cash so technically it has to say this ‘You dont have enough cash to buy this’ but he is not saying that cause his cash was first higher then the amount.
Can someone help me with this?
If you need the script here it is;
local leaderstats = player.leaderstats
local hover = game.SoundService.HoverSound
if Cash.Value < 300 then -- checks if the cash is under 300
script.Parent.Parent.Text = "You don't have enough cash to buy this!" -- sets the text to this
script.Parent.Text = "Close"
else
script.Parent.Parent.Text = "This will cost: $300 Are you sure?"
end
script.Parent.MouseEnter:Connect(function()
hover:Play()
end)
script.Parent.MouseButton1Click:Connect(function(click)
if Cash.Value < 300 then
warn("You dont have enough cash")
script.Parent.Parent.Visible = false
else
script.Parent.Parent.Text = "This will cost: $300 Are you sure?"
script.Parent.Text = "Purchase"
script.Parent.Purchase.Disabled = true -- disables the script
print("PurchaseScript has been disabled") -- prints what happening
Cash.Value = Cash.Value - 300 -- sets the cash to min 300
print("leaderstats has been changed with -300")
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.BackGround.Philips.PriceSetter.Visible = true
script.Parent.Parent.Parent.BackGround.Philips.Selection.Visible = false
wait(5)
local philipsclone = game.ReplicatedStorage.Tvs.Philipstv1.PartsOfPhilips:Clone()
philipsclone.Parent = game.Workspace
local position = game.ReplicatedStorage.Tvs.Philipstv1.PartsOfPhilips.Screen
-- dit en de regel eronder is voor de positie waar hij word gecloned dus in de machine
for i, v in pairs(philipsclone:GetChildren()) do
v.Anchored = false
v.CanCollide = true
v.Transparency = 0
end
-- positions
local rotatepositionCFrame = CFrame.Angles(0,math.rad(0), 0)
position.CFrame = position.CFrame:ToWorldSpace(rotatepositionCFrame)
print("The CFrame has been set")
wait(10)
wait(30)
print("30 Seconds are over!")
script.Parent.Parent.Parent.BackGround.Philips.PriceSetter.Visible = false
script.Parent.Parent.Parent.BackGround.Philips.Selection.Visible = true
script.Disabled = false
print("PurchaseScript has been enabled")
game.StarterGui.ComputerMenu.Menu1.Philips1Info.PurchaseChecker.Purchase.Purchase.Disabled = false
end
end)
I’m not sure if that will work. And the last time i’ve been working with remote events is a long time ago so i don’t think that i can remember how to use them.
I don’t really know if this would be very helpful in my script. Cause remote events are used to connect stuff from a script to another script for example;
a player clicks on a button with a script and then the other script that is connected with the first script cause of the remote event then the second script will run and do something.
Am i right or is this totally not what it is? And if it is how can i use it for a value checker
wait(10) -- i put this in here so i can change the value to less or higher before it starts running
game.StarterGui.ComputerMenu.Menu1.Philips1Info.PurchaseChecker.Purchase.Purchase.Disabled = true
local player = game.Players.LocalPlayer
local Cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
local leaderstats = player.leaderstats
local hover = game.SoundService.HoverSound
if Cash.Value < 300 then -- checks if the cash is under 300
script.Parent.Parent.Text = "You don't have enough cash to buy this!" -- sets the text to this
script.Parent.Text = "Close"
else
script.Parent.Parent.Text = "This will cost: $300 Are you sure?"
end
script.Parent.MouseEnter:Connect(function()
hover:Play()
end)
script.Parent.MouseButton1Click:Connect(function(click)
if Cash.Value < 300 then
warn("You dont have enough cash")
script.Parent.Parent.Visible = false
else
script.Parent.Parent.Text = "This will cost: $300 Are you sure?"
script.Parent.Text = "Purchase"
script.Parent.Purchase.Disabled = true -- disables the script
print("PurchaseScript has been disabled") -- prints what happening
Cash.Value = Cash.Value - 300 -- sets the cash to min 300
print("leaderstats has been changed with -300")
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.BackGround.Philips.PriceSetter.Visible = true
script.Parent.Parent.Parent.BackGround.Philips.Selection.Visible = false
wait(5)
local philipsclone = game.ReplicatedStorage.Tvs.Philipstv1.PartsOfPhilips:Clone()
philipsclone.Parent = game.Workspace
local position = game.ReplicatedStorage.Tvs.Philipstv1.PartsOfPhilips.Screen
-- dit en de regel eronder is voor de positie waar hij word gecloned dus in de machine
for i, v in pairs(philipsclone:GetChildren()) do
v.Anchored = false
v.CanCollide = true
v.Transparency = 0
end
-- positions
local rotatepositionCFrame = CFrame.Angles(0,math.rad(0), 0)
position.CFrame = position.CFrame:ToWorldSpace(rotatepositionCFrame)
print("The CFrame has been set")
wait(10)
wait(30)
print("30 Seconds are over!")
script.Parent.Parent.Parent.BackGround.Philips.PriceSetter.Visible = false
script.Parent.Parent.Parent.BackGround.Philips.Selection.Visible = true
script.Disabled = false
print("PurchaseScript has been enabled")
game.StarterGui.ComputerMenu.Menu1.Philips1Info.PurchaseChecker.Purchase.Purchase.Disabled = false
end
end)