Hello Developers!
I was making game type of clicking game but it is not simulator
My Plan was when ever player clicks the screen player gets less click
I did it correctly so far but now with datastore it is not working
I put MouseButton1Click Function on the local script cause i cant get player leaderstats from Server Script
When player clicks Mouse get less click but it is on local script so it is only be like client sided whenever player rejoins the stats is not same cause player not getting less clicks from Server Side
If you guys have any Suggestions
Please Reply Back
Anyways Thanks!
Use remote events.
When the player clicks it fires a remote event to increase whatever leaderstat’s value.
When the client fires a RemoteEvent using FireServer, it also sends in the player. Like so:
game:GetService("UserInputService").InputBegan:Connect(function(input, gamepross)
if gamepross then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireServer() -- whatever the remote event u insert is
end
end)
On a serverscript:
game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):OnServerEvent:Connect(function(player) --the player who made the event fire is sent everytime.
local coin = player.leaderstats:FindFirstChild("Coins") -- whatever the leaderstat value is
coin.Value += 1 -- gives player one coin
end)
This should make the leaderstat value save for server