Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Points not given to my user only (points aren't given to me and only me) ?

Asked by 6 days ago

I made a Points System for a cafe, when I tried to test it, I gave a tool to the owner and it worked but I didn't get a point, but then she gave me a tool and she got a point.

When I searched for the problem in the studio, I found a player in the players folder, the player had my name, I wasn't running the game in the studio, and it can't be removed, I am not sure how to fix it.

This is the Points System script:

local DataStoreService = game:GetService("DataStoreService")
local PointsStore = DataStoreService:GetDataStore("PointsStore")

game.Players.PlayerAdded:Connect(function(Player)
    local SavedPoints = PointsStore:GetAsync(Player.UserId)

    local Leaderstats = Instance.new("Folder", Player)
    Leaderstats.Name = "leaderstats"

    local PointsValue = Instance.new("IntValue", Leaderstats)
    PointsValue.Name = "Points"

    if SavedPoints ~= nil then
        PointsValue.Value = SavedPoints
    end

    PointsValue.Changed:Connect(function(NewPoints)
        PointsStore:SetAsync(Player.UserId, NewPoints)
    end)
end)

This is the GiveItem script:

game.ReplicatedStorage.GivePlayerItem.OnServerEvent:Connect(function(Player, PlayerName)
    if Player.Name ~= PlayerName then
        local ToolToGive = Player.Character:FindFirstChildWhichIsA("Tool")
        ToolToGive.Parent = game.Players[PlayerName].Backpack
        Player.leaderstats.Points.Value = Player.leaderstats.Points.Value + 1
    end
end)

Any help would be greatly appreciated.

Answer this question