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

How to make Killed the Creator badge script into Killed BY Creator Script?

Asked by 7 years ago
Edited 7 years ago

Hi, I was wondering how I would convert my badge script for killing the creator to work when you are killed BY the creator instead. Would I just switch some things around, or would it be different?

01local badgeId = 575373257
02 
03function awardBadgeOnDeath(player, badgeId)
04    player.CharacterAdded:connect(function(char)
05        char.Humanoid.Died:connect(function()
06            local killer = char.Humanoid:FindFirstChild("creator")
07            if killer then
08                game:GetService("BadgeService"):AwardBadge(killer.Value.userId, badgeId)
09            end
10        end)
11    end)
12end
13 
14game.Players.PlayerAdded:connect(function(player)
15    if player.userId == game.CreatorId then
16        awardBadgeOnDeath(player, badgeId)
17    end
18end)

Also, this original script only works half the time. What's wrong?

2 answers

Log in to vote
1
Answered by 7 years ago

First of all, let's remake the script to work for all players and be a little improved. I've split it up to 3 parts.

Minor fixes and removing the creator check.

What you need to do is remove the function awardBadgeOnDeath and copy the script part and replace the if the player is a creator.

Checking who is the killer

But now it will award badges if you kill anyone? We need to add an if question to see if the killer's id matches game.CreatorId

The Code

This is the code I managed to come up with.

01local badgeId = 575373257
02 
03function awardBadgeOnDeath(player, badgeId)
04    player.CharacterAdded:connect(function(char)
05        char.Humanoid.Died:connect(function()
06            local killer = char.Humanoid:FindFirstChild("creator")
07            if killer then
08                game:GetService("BadgeService"):AwardBadge(killer.Value.userId, badgeId)
09            end
10        end)
11    end)
12end
13 
14game.Players.PlayerAdded:connect(function(player)
15    function awardBadgeOnDeath(player, badgeId)
View all 28 lines...
0
Thank you very much! This is for being killed by the creator, right? What would be changed for the original script to killing the creator? LuckyAura -1 — 7y
0
Hello? Not sure which one it is, but it doesn't seem to be working still. :-( LuckyAura -1 — 7y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Firstly, we want to make sure you put the script into ServerScriptService. If this still doesn't work, try to move it in different places. Secondly, make sure you placed YOUR creator ID and YOUR badge ID.

The code bartekrabit came up with was this:

01local badgeId = 0000 (PUT YOUR BADGE ID)
02local userId = 0000 (PUT YOUR USER ID)
0302  
0403  function awardBadgeOnDeath(player, badgeId)
0504      player.CharacterAdded:connect(function(char)
0605          char.Humanoid.Died:connect(function()
0706              local killer = char.Humanoid:FindFirstChild("creator")
0807              if killer then
0908                  game:GetService("BadgeService"):AwardBadge(killer.Value.userId, badgeId)
1009              end
1110          end)
1211      end)
1312  end
1413  
1514  game.Players.PlayerAdded:connect(function(player)
View all 29 lines...

I've re-written it a bit and modified some stuff. You must put it in ServerScriptService and if it still doesn't work, seek further help from YouTube, google etc. Another suggestion would be placing the script in other places like WorkSpace, etc.

This script actually DID work for me so I'm guessing it'll help you aswell.

The reason it may not ALWAYS work was because you must've written something wrong in the script which i already covered. This IS for when you kill the owner and not when the owner kills you. Modifiying the script to make it when the owner kills you should be easy. There are some tutorials, if not many tutorials on YouTube for similar things. There are model scripts aswell so inserting them into your game wouldn't be a harm. If you want to learn how the script works if you didn't script it yourself, look through the script and make sense/search up what they mean.

Hope this all helped.

p.s: this worked for me.

Answer this question