Hello Scripters! I have tried to make a script so that when you kill a zombie you get money. When I kill this zombie with a sword it works. But when I kill it with a gun, it dosent. Its because when you kill it with a sword it puts a value into the humanoid of the zombie which is the latest player that has damaged the zombie. But the gun dosent put that value, I have tried for 3 hours but I still cant do it. Can someone who does know how to do this use team create to go on my game and make it work? i just really want to make this fun game for my freinds to enjoy and am on just a roadblock. Helping me and clearing that roadblock will be highly appreciated!
Have u create leaderstats? i got a script.
Yes of course I have leaderstats its called “Money”
Alright give me a sec i got a script.
Okay thanks but how would the script know who has killed it if the gun doesn’t send the info. The sword does send the info and it works but the gun doesn’t and I need help on making the gun send the info. But if your script works than
Insert a server script in ur NPC and in it say:
local Money = Player:WaitForChild(“leaderstats”):WaitForChild(“Money”)
Money.Value = Money.Value +10
insert a remote event in replicated storage
insert a local script in startergui and in it say:
Normally the leaderboard script uses an old style ‘tagging’ system where every hit by a weapon inserts an ObjectValue into the character so that when they die, the value points to the player who last damaged them and the leaderboard script knows who to give the points to. You just need to modify your gun to add a tag the same way that the sword does.
Sorry I think youve done something wrong. Do you mean insert a local script into the NPC and insert a server script into server script service?
Yes so thats the problem I dont know how to make the gun add tags. I can team create with you for you to modify the gun so that it does put tags
He is a troll and will probably complicate your system some more. Can you show the scripts in the gun and sword, mainly the ones that are responsible for dealing damage to the players/zombies?
Wait what ThoseNamesAreGood is a troll?
the scripts in the sword and especially the gun is very long so I think its better to use team create.
Hello I struggled with a problem very similar and this is what I came up with: Put this in server script service. It’s a server script
local function isZombie(model)
return model and model:IsA(“Model”) and model.Name == “Zombie”
local function checkChild(child)
if isZombie(child) then
if player.team2.which.Value == 1 then
-- Code here (: end end) end end for _, child in pairs(workspace:GetChildren()) do checkChild(child) end workspace.ChildAdded:Connect(checkChild)
So I dont put anything in the zombie?
Also what code do I put in the “Code here” area? Do I put the code to give the player money?
No you don’t need to (: (: 30 charr
Pasting a generic patch into your game might not solve your problem, because we have no idea how your game works. We need to see some code to understand how your weapons add Money to the players. You said that the sword works so you’d just need to modify the gun to do the same thing that the sword is doing.
Thanks I will do this and after reading the script it does make sense. But how about if a put multiple zombies? Does it still work?
I now what your trying to do but like many things in life, there is more than 1 option im gonna see what Olinator21 has and if his/hers script dosent work then I will use your way
You can either put multiple scripts and change “zombie” to the name of the other zombie or make an or statement