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

BlindableEvent giving coins every player instead of what?

Asked by 3 years ago

Hello there! I've got two BlindableEvents in ServerStorage called "Give2" and "Give3". When they are fired I want them to increase or decrease the value for the player who fired them. The matter is that the event is applied for every player in the server. Can someone help me? ServerScript:

local Datastore = game:GetService("DataStoreService")
local ds2 = Datastore:GetDataStore("FaultsSaveSystem")
game.Players.PlayerAdded:Connect(function(plr)
    local folder = Instance.new("Folder")
    folder.Name = "leaderstats"
    folder.Parent = plr
    local val2 = Instance.new("NumberValue")
    val2.Name = "Faults"
    val2.Value = ds2:GetAsync(plr.UserId) or 0
    val2.Parent = folder
    game.ServerStorage.Give2.Event:Connect(function(Amount)
        val2.Value = val2.Value + 1
    end)
    game.ServerStorage.Give3.Event:Connect(function(Amount)
        if val2.Value ~= 0 then
            val2.Value = val2.Value - 1
        end
    end)
    val2.Changed:Connect(function()
        ds2:SetAsync(plr.UserId, val2.Value)
    end)
end)

1 answer

Log in to vote
0
Answered by 3 years ago

I Don't Know Exactly What Is Going On Because I Am Not That Advanced, But This "Player.Added" Event Gets All The Players In The Game Because They Have Been Added Into The Game Hence, It Happens To All The Player. I Don't Know If This Is True. Just My Theory

Ad

Answer this question