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

[URGENT!] Make a event executable by all players?

Hello. I was wondering how I can turn this event, into an event executable by all players.

game.Players(Any player).Character.HumanoidRootPart.Touched:Connect(function(hit)
    if game.Players:FindFirstChild(hit.Parent.Name) and hit.Parent:FindFirstChild("Humanoid") then -- we know its a real player
        local targets_humanoid = hit.Parent:FindFirstChild("Humanoid")
        targets_humanoid.Health = 0
    end

2 comments

0

What do you want it to do?

0

Kill a player when a player is touched but only if killer is in seeker team

1 answer

All you have to do is to make it a server script, then when a part touches, check if there is a humanoid and kill it. If you want to make it only for players and not NPC's you have to check if the character is a players character with players:GetPlayerFromCharacter()

You also have to check their team if you only want it to kill the "Seeker" team.

local part = script.Parent
local seekerTeam = game:GetService("Teams"):FindFirstChild("Seeker")

local function hit(part)
	local humanoid = part.Parent:FindFirstChildWhichIsA("Humanoid")
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if humanoid and player and player.Team == seekerTeam then
		humanoid:TakeDamage(humanoid.MaxHealth)
	end
end

part.Touched:Connect(hit)

3 comments

0

But what if we replace the part with a player, so when seeker (the part for your case) touches a player, the targeted player dies? [By the way, thank you for the awnser]

0

I'm not sure I understand, is the targeted player the one who touches or who is that?

0

I mean...could you replace the part with the seeker's character?

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