game.Players.PlayerAdded:Connect(function(plr)
script.Parent.MouseButton1Click:Connect(function()
if plr.leaderstats.Coins.Value >= script.Parent.Cost.Value then
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value - script.Parent.Cost.Value
workspace.Events.UpgradeSM:FireAllClients(plr)
script.Parent.Cost.Value = script.Parent.Cost.Value*1.1
else
print("not enough")
end
end)
end)
ive tried using fireallclients and it aint workin
I think you have the right idea, it’s just done the wrong way
You’d need to replicate the text to all clients, so instead use FireServer()
and get all the players using GetPlayers()
through a loop?
You could probably try this instead:
--Your script
local Event = game.ReplicatedStorage.Events:WaitForChild("UpgradeSM") --I'd recommend placing it there instead
local Player = game.Players.LocalPlayer
local leaderstats = Player:WaitForChild("leaderstats")
local Cost = script.Parent.Cost
script.Parent.MouseButton1Click:Connect(function()
if leaderstats.Coins.Value >= Cost.Value then
FireServer(Cost)
else
print("Not enough")
end
end)
--Server Script in ServerScriptService
local Event = game.ReplicatedStorage.Events:WaitForChild("UpgradeSM")
Event.OnServerEvent:Connect(function(Player, CurrentCost)
local leaderstats = Player:WaitForChild("leaderstats")
leaderstats.Coins.Value -= CurrentCost.Value
for _, Stuff in pairs(game.Players:GetPlayers()) do
local PlayerGui = Stuff:WaitForChild("PlayerGui")
local MainGui = PlayerGui:WaitForChild("ScreenGui")
MainGui.Cost.Value *= 1.1
MainGui.UpgadeMultiplier.Text = "Upgrade Server Multi by x"..MainGui.Cost.Value
MainGui.CurrentMultiplier.Text = "The current server multi is: "..MainGui.MultiplierThingy.Value.."x"
end
end)
Ok so i took ur scripts and umm it went from 90,000B to -50,000
Wait w h a t
Oh wait maybe I see the issue? Actually could you print out what CurrentCost.Value
& Cost.Value
is supposed to be?
its supposed to be 50000 coins