Doen’t works either. Any other suggestions?
I saw this in ur scripts
game.StarterGui.ComputerMenu.Menu1.Philips1Info.PurchaseChecker.Purchase.Purchase.Disabled = true
Also this
script.Parent.Purchase.Disabled = true
Are u disabling the script twice?
Not anymore but then why didnt it disable the script but that is a other problem first we need to solve this one.
How about u try to put a value inside thing that u want to buy and check if the player cash is more or equals to the value …then , do stuff.
Do u mean that there needs to be a script inside the model that checks if the value is less than 300?
I mean try to put a price inside the value and parented it to the thing that u want to clone.then check if player cash is more than than the price value then do stuff
Do you mean with a boolean? Otherwise I really don’t know what you mean.
I mean number or int value.put the price in there and parented it to the model.srry if u not understand .its hard to explain in mobile
Why are you doing this on the client? An exploiter can easily give themself as much cash as they want. It won’t work anyways, the server cannot see client changes.
Instead, use a RemoteFunction, invoke it on the client, and then on the server, check if the player has enough cash, remove the cash, and return a result to the client.
I thought remote event can also prevent some exploiters
It can but a remoteFunction can return data, unlike an event.
If I put all the things from this local script to a normal script, and a player clicks the button wouldn’t it appear for the entire server? And can u show me an example of how you use remote functions in my script so no exploiters can give themself cash or all that stuff?
All of my GUI’s are scripted with local scripts, so should change that into a normal script or is that not necessary? Or do I need to use remote functions for these too?
I can’t really explain all of it, but here’s the framework:
When the player clicks the button, Invoke the server with the item name, on the server, check if the player has enough cash to buy that item, the first argument of remote events and functions is always the player.
Then, if the player has enough cash, give the player the item and -increment the product price. Return some data to the client that contains if the purchase succeeded, and if it didn’t, the message to tell that client why it didn’t (such as if they didn’t have enough currency)
Hope this helps!
Here’s a few questions I hope you can answer them:
- Where does that script needs to be in?
- Do you still need a script/localscript inside the button? With the .MouseButton1Click() function?
- If yes does the remote function connects with the script/localscript?
And the last question:
Can you answer this ^?
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)
Try this
I don’t see what you changed to the script if you can tell me what you changed that would be helpfull.
-- Server
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPopupRequest = Instance.new("RemoteFunction")
createPopupRequest.Name = "CreatePopupRequest"
createPopupRequest.Parent = ReplicatedStorage
Players.CharacterAutoLoads = false
local function onPlayerAdded(player)
createPopupRequest:InvokeClient(player)
player:LoadCharacter()
end
Players.PlayerAdded:Connect(onPlayerAdded)
-- ==================================================
-- LocalScript
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local createPopupRequest = ReplicatedStorage:WaitForChild("CreatePopupRequest")
local function onCreatePopupRequested()
local screen = Instance.new("ScreenGui")
screen.Parent = playerGui
local closeButton = Instance.new("TextButton")
closeButton.Text = "Welcome to the game! Click me to play!"
closeButton.Size = UDim2.new(0, 300, 0, 50)
closeButton.Parent = screen
closeButton.MouseButton1Click:Wait()
closeButton.Visible = false
end
createPopupRequest.OnClientInvoke = onCreatePopupRequested
I got this script from the dev hub but in this script there is this ‘–==========’ and then below that it says local script, but at the top of the script it says server. Can someone explain that?
And in the onPlayerAdded() function. In that function needs to be if Cash.Value < 300 then bla bla or am i wrong?
You might want to try using the changed events and then double checking if the cash is below 300$
Btw, does this change the fact that it can update the cash so it knows when he bought something that it will change immediately when he got less cash or higher cash?