Alright like @OriginalDevelops said, you need a RemoteEvent to let ServerScript and LocalScript communicate.
Therefore, you need to put a RemoteEvent in ReplicatedStorage since the LocalScript cannot access ServerStorage.
In LocalScript (This LocalScript should be placed into the ImageButton):
local Clicked = false
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
script.Parent.MouseButton1Click:Connect(function()
if Clicked == false then
Clicked = true
RemoteEvent:FireServer()
wait(1)
Clicked = false
end
end)
In ServerScript (You can use your original ServerScript in the question you asked):
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
game.Players.PlayerAdded:Connect(function(Player)
local Stats = Instance.new("Folder",Player)
Stats.Name = "leaderstats"
local DiceRolls = Instance.new("IntValue",Stats)
DiceRolls.Name = "Dice Roll's"
DiceRolls.Value = 0
local Cash = Instance.new("IntValue", Stats)
Cash.Name = "Cash"
Cash.Value = 0
while wait() do
RemoteEvent.OnServerEvent:Connect(function(Player)
Player.Stats.Cash.Value = Player.Stats.Cash.Value + 1
end)
end
end)
4 comments
This doesn't seem to add 1 to my leader stats. Every single script i have tried hasn't either. I can let you help me in Roblox Studio if you would like.
You have to friend me in Roblox though
Send me, I will accpect and solve for you when I’m break!
Thank you!