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

I want to give players kills, but the script doesn't working.DId i do something wrong??

Asked by 5 years ago
Edited 5 years ago
1local This = script.Parent
2This.Touched:Connect(function(Characters)
3    local Players = game.Players:GetPlayerFromCharacter(Characters.Parent)
4    local Aye = Characters.Parent:FindFirstChild("Humanoid")
5    if not Aye == nil then
6 
7        Players.leaderstats.Kills.Value = Players.leaderstats.Kills.Value
8        end
9end)

I touched the part, but it doesn't give me kills( i created leaderstats and it works very well)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Well it can be this lines

1Players.leaderstats.Kills.Value = Players.leaderstats.Kills.Value

because the value of your kills is equal to your number of kills so let's edit it

01--Copy only this lines
02local This = script.Parent
03This.Touched:Connect(function(Characters)
04    local Players = game.Players:GetPlayerFromCharacter(Characters.Parent)
05    local Aye = Characters.Parent:FindFirstChild("Humanoid")
06    if Aye then
07 
08        Players.leaderstats.Kills.Value = Players.leaderstats.Kills.Value + 1
09        end
10end)

This is the problem. So the kills of the player is equal to the kills of the player so if you want to add the kills for the player just add

1Players.leaderstats.Kills.Value = Players.leaderstats.Kills.Value + 1

So if the kills of the one player is 25 and the function call, the kills of that player will be added by 1. So if you want the player touched once the part use debounce. And you can replace 1 to any number of kills that you want to add in the player's kills. WARNING:Use only the script above

0
Tried, but still, there's nothing changed when i clicked play,It's still doesn't give me 1 kill Creeperdo123 -17 — 5y
0
There's nothing shows in output window so i can't know what is the problem Creeperdo123 -17 — 5y
0
i will edit it robloxsario 76 — 5y
0
ummm just i edit the part "if not Aye == nil" because Aye is not nil but just use only "if Aye then" to understand the script better robloxsario 76 — 5y
View all comments (2 more)
0
re copy the script again robloxsario 76 — 5y
0
It seems like not the script problem, but the game problem.Anyways, thanks for the answer :> Creeperdo123 -17 — 5y
Ad

Answer this question