Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I combine two scripts without interfering?

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

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

2 comments

0

Hey, thanks for the reply. Which line would I put that in? Sorry for all the questions.

0

Maybe add it on Line 6?

This discussion is preserved as it was. New answers, comments, and votes are closed.