did I delete that- I don’t remember deleting it
I think maybe I should try that the script it’s going to be very is error what is the problem is how to fix it
Please do not listen to @Eac12a, he obviously does not know what he is doing. Please trust @Forummer, he is able to solve your problem.
OK I will not listen to her we know maybe
Can I see a code example for that?
Nevermind
No we don’t want to see code that maybe you not I’m not sure if you want what you’re doing
I have re-made the whole scripts and it should work now. I fixed some bugs on where it would stop because of the infinite update loop and the Upgrade Remote not working due to the fact you were giving the wrong parameters. (I’ve also done some optimizations)
-- Client Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local LocalLeaderstats = LocalPlayer:WaitForChild("leaderstats")
local LocalUpgradestats = LocalPlayer:WaitForChild("upgradestats")
local CashStats = LocalLeaderstats:WaitForChild("Cash")
local UpgradeStats = LocalUpgradestats:WaitForChild("Upgrade")
local UpgradeRemoteEvent = ReplicatedStorage:WaitForChild("Upgrade")
local PriceLabel = script.Parent.Price
local LevelLabel = script.Parent.Level
local SubmitButton = script.Parent.Submit
local StarterPrice = 150
local RenewedPrice = StarterPrice * UpgradeStats.Value
UpgradeStats:GetPropertyChangedSignal("Value"):Connect(function()
RenewedPrice = StarterPrice * UpgradeStats.Value
PriceLabel.Text = string.format("Price: %d Cash", RenewedPrice)
LevelLabel.Text = string.format("Your Level: %d", UpgradeStats.Value)
end)
SubmitButton.Activated:Connect(function()
UpgradeRemoteEvent:FireServer(RenewedPrice)
print("[UpgradeRemoteEvent (Client)]: Fired to the Server!")
end)
-- Server Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpgradeRemoteEvent = ReplicatedStorage:WaitForChild("Upgrade")
UpgradeRemoteEvent.OnServerEvent:Connect(function(Player, Price: number)
local UpgradeStats = Player:FindFirstChild("upgradestats") or nil
local Leaderstats = Player:FindFirstChild("leaderstats") or nil
local Upgrade = if UpgradeStats then UpgradeStats:FindFirstChild("Upgrade") else nil
local Cash = if Leaderstats then Leaderstats:FindFirstChild("Cash") else nil
if Cash and Upgrade then
if Cash.Value > (Price - 1) then
Cash.Value -= Price
Upgrade.Value += 1
print("[UpgradeRemoteEvent (Server)]: Player is able to Upgrade!")
else
print("[UpgradeRemoteEvent (Server)]: Player is not able to Upgrade!")
end
end
end)
Isn’t it better to use Changed or GetPropertChangedSignal or RunService instead of a while wait() do loop.
If price
were a reference to a value object, yes, in this case however it just stores a number value (of which ‘GetPropertyChangedSignal’ isn’t a valid member for).