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

Player is not getting Rep for every kill?

Asked by 5 years ago

I want to make it to where the player gets Rep everytime they kill someone but it does not work.

01local DataStore = game:GetService("DataStoreService")
02local SlayerStore = DataStore:GetDataStore("SlayerStore")
03 
04 
05game.Players.PlayerAdded:Connect(function(player)
06    local leaderstats = Instance.new("Folder",player)
07    leaderstats.Name = "leaderstats"
08 
09    local Rep = Instance.new("IntValue", leaderstats)
10    Rep.Name = "Reputation"
11    Rep.Value = SlayerStore:GetAsync(player.UserId) or 100
12 
13 
14 
15 
View all 37 lines...

1 answer

Log in to vote
0
Answered by 5 years ago

You will reverse the character added and the player removing and don't use the LocalPlayer cause that's for only Local Script

Copy this code

01local DataStore = game:GetService("DataStoreService")
02local SlayerStore = DataStore:GetDataStore("SlayerStore")
03 
04 
05game.Players.PlayerAdded:Connect(function(player)
06    local leaderstats = Instance.new("Folder",player)
07    leaderstats.Name = "leaderstats"
08 
09    local Rep = Instance.new("IntValue", leaderstats)
10    Rep.Name = "Reputation"
11    Rep.Value = SlayerStore:GetAsync(player.UserId) or 100
12 
13    print("Loaded!")
14 
15   player.ChracterAdded:Connect(function(character)-- Use the variable player. The script will know cause of the word CharacterAdded event so it means the player's character
View all 32 lines...

Its not tested! I wish will worked!

Ad

Answer this question