Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make this script add it to the other value?(SOLVED)

Asked by 4 years ago
Edited 4 years ago
script.PPS.OnServerEvent:connect(function(plr)
    plr.leaderstats.Parts.Value = plr.leaderstats.Parts.Value + plr.leaderstats.PPS.Value
end)
while true do
    workspace.Events.PPS:FireServer()
    wait(1)
end

When i go to the shop in my game, and buy a Clicker it gives me the 1 PPS, but doesn't give me it added to my Parts every second. How can i make this work?

1 answer

Log in to vote
0
Answered by
megukoo 877 Moderation Voter
4 years ago

This is because you are attempting to use :FireServer() on the server. Sorry to say, but you don't need a remote event for something like this.

I assume you want to make every player in the server receive a "Part", but you don't really know how to grab the player.

You can use loops to achieve this. Following example is in a server script.

local Players = game:GetService("Players")

while true do
    for i, plr in pairs(Players:GetPlayers()) do -- go through every player in the game, and give them Parts based on their Parts Per Second
        plr.leaderstats.Parts.Value = plr.leaderstats.Parts.Value + plr.leaderstats.PPS.Value
    end
    wait(1)
end
Ad

Answer this question