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

Converting a "You Killed the Creator" script into a "The Creator Killed You" script (?)

Asked by 2 years ago

For reference, this script was made by someone on DevForum. I forget their username, but I would ask them if I could.

However, I have been wanting to flip this script backwards:

local BadgeID = 00000
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")

Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")

        Humanoid.Died:Connect(function()
            if Character.Name == "MrOctoFoam" then
                local creator = Humanoid:FindFirstChild("creator")
                if creator and creator.Value then
                    local Killer = creator.Value
                    BadgeService:AwardBadge(Killer.UserId, BadgeID)
                end
            end
        end)
    end)
end)

I gave it a couple shots trying to flip it around, but I failed both times. Since I am barely a novice with scripting, and I have been despite being on the platform for 10+ years, I cannot figure it out.

Can someone make this script award a badge to a player who was killed by me/the creator? All help is extremely appreciated.

1 answer

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
2 years ago
Edited 2 years ago

You try to identify yourself with your name, This is unstable because if you change your name the script won't work anymore!

I cooked up a new code for you using your old one! I haven't tried it before so it might not work, But comment if anything goes wrong, If it works than I'd appreciate if you accepted my answer!

Hope you have a great rest of your day!

local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")

local BadgeID = 00000 -- Enter the: You killed the Creator! ID here
local Badge2ID = 00000 -- Enter the: The Creator Killed You! ID here
local ownerId = 00000 -- Enter your id in here!

Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")

        Humanoid.Died:Connect(function()
            if Player.UserId == ownerId then
                local creator = Humanoid:FindFirstChild("creator")
                if creator and creator.Value then
                    local Killer = creator.Value
                    BadgeService:AwardBadge(Killer.UserId, BadgeID)
                end
            else
                local creator = Humanoid:FindFirstChild("creator")
                if creator and creator.Value == Players:GetNameFromUserIdAsync(ownerId) then
                    local Killer = creator.Value
                    BadgeService:AwardBadge(Player.UserId, Badge2ID)
                end
            end

        end)
    end)
end)
0
Super-huge thank you my friend! MrOctoFoam 0 — 2y
0
Oh, wait, I'm afraid the "The Creator Killed You!" segment of the script still is not working. I've put in the right badge ID and I've put in the right user ID, so I don't know what it could possibly be? MrOctoFoam 0 — 2y
Ad

Answer this question