Is it possible to make a brick that only kills players and not the place owner?
Any help is appreciated.
It is possible to do so. Here is how I would do it:
local OwnerId = game.CreatorId -- Userid of owner
script.Parent.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent) -- The player that touched kill part
local Humanoid = hit.Parent:FindFirstChild("Humanoid") -- The character's humanoid
if hit.Parent and Humanoid then
if Player.UserId == OwnerId then -- If player's userid matches the owner's userid, don't do anything
print("Player is owner, not damaged") -- Do whatever you want on this line
else
Humanoid.Health = 0 -- Kill player
end
end
end)
The script is in the kill-part. (Not local script.)
Gets the owner of the game automatically for you, and if someone that isn’t the owner attempts to touch the brick they’ll die.
script.Parent.Touched:Connect(function(hit)
local Character = hit.Parent
if Character:FindFirstChild("Humanoid") then
local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
if not Player.UserId == game.CreatorId then
Character.Humanoid.Health = 0
end
end
end)
The table is not necessary, as he only wanted the game owner not do die, not any admins.
You could make a table of admins and the owners user ID, then check the player who touched the part, if the player is in the table then do nothing, if the player is not in the table, then kill the player…
With a table, its more customizable, your able to add anyone you want to a white list (including the owner)
It is indeed more cuztomizable, I agree.
Bruh, why did you edit your OwnerID to game.CreatorID when it was originally customizable.
I, uh, don’t know. Maybe he wants to customize it, it is indeed possible I see now. My bad.
No it’s fine, I was just kind of confused. Haha