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

How do I combine two scripts without interfering?

Asked by 4 years ago

I'm not exactly sure how to combine two scripts, but I have my base script here to detect when a player has died and send it to discord

local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")   
    game:GetService('Players').PlayerAdded:Connect(function(player)
        player.CharacterAdded:Connect(function(player)
            player:WaitForChild("Humanoid").Died:Connect(function()
                local data = {
                content = player.Name .. " has died!";
                username = "KillBot",
                avatar_url = "http://www.roblox.com/Thumbs/Avatar.ashx?x=200&y=200&Format=Png&username="..player.Name

  }
                    print(player.Name .. " has died!")
                    local webhook = "https://discordapp.com/api/webhooks/00000000000"       

            HttpService:PostAsync(webhook, HttpService:JSONEncode(data))
            end)
        end)
    end)

How would I go about adding this to the script?

if Humanoid:FindFirstChild("creator") ~= nil then
                local Killer = Humanoid.creator.Value 

Everytime I add the last one I get an error saying end expected (. Thank you for the help.

1 answer

Log in to vote
0
Answered by
Wiscript 622 Moderation Voter
4 years ago
local creator = Humanoid:FindFirstChild("creator")
if creator then -- every if statement is followed by an end afterwards
    local killer = creator.Value
end -- this is to show the "end" of the stuff that happens after the if statement

If you have any questions, let me know <3

0
Hey, thanks for the reply. Which line would I put that in? Sorry for all the questions. Jensmed 0 — 4y
0
Maybe add it on Line 6? Wiscript 622 — 4y
Ad

Answer this question