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

Help with a floor that kills non-admins?

Asked by 10 years ago

Ok, so I made an admin room where admins spawn when they enter, I've got it fully functioning and a door so they can get out, only problem is, what if the winner's room includes a fly or teleport tool..? (Which it will) so how would I code a script in the floor to make it kill non-admins should they somehow enter the room using a tool? I think it would be pretty much like the door, except that it wouldn't teleport an admin to the other side (the bottom) but wouldn't affect an admin at all, only to kill a non-admin. Any suggestions? The door code is this:


--| WaitForChild |--

-- Waits for parent.child to exist, then returns it local function WaitForChild(parent, childName) assert(parent, "ERROR: WaitForChild: parent is nil") while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end return parent[childName] end

--| Variables |--

local GamePassService = Game:GetService('GamePassService') local PlayersService = Game:GetService('Players')

local VipDoor = script.Parent

local GamePassIdObject = WaitForChild(script, 'GamePassId')

local JustTouched = {}

--| Functions |--

-- Finds out which side the player is on and teleports them to the other local function TeleportToOtherSide(character, hitPart) local bottomOfDoor = VipDoor.CFrame.p - Vector3.new(0, VipDoor.Size.Y / 2, 0) local inFrontOfDoor = bottomOfDoor + VipDoor.CFrame.lookVector * 3 local behindDoor = bottomOfDoor - VipDoor.CFrame.lookVector * 3

local distanceToFront = (inFrontOfDoor - hitPart.Position).magnitude
local distanceToBack = (behindDoor - hitPart.Position).magnitude
if distanceToFront < distanceToBack then
    character:MoveTo(behindDoor)
else
    character:MoveTo(inFrontOfDoor)
end

end

-- When a player with the game pass touches the door, teleport them to the other side local function OnTouched(otherPart) if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then local player = PlayersService:GetPlayerFromCharacter(otherPart.Parent) if player and not JustTouched[player] then JustTouched[player] = time() if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then TeleportToOtherSide(player.Character, otherPart) end end end end

-- Removes old entries in JustTouched local function RemoveOldTouches() for player, touchTime in pairs(JustTouched) do if time() > touchTime + 0.3 then JustTouched[player] = nil end end end

--| Script Logic |--

VipDoor.Touched:connect(OnTouched)

while true do RemoveOldTouches() wait(1/30) end


1 answer

Log in to vote
0
Answered by 10 years ago

Lol'd easy.

T-Shirt Way

function Touched(plr)
local ifs = plr.T-Shirt.Texture = "T-SHIRT ID"
if ifs then
print("GOOD")
else
plr.Humanoid.Health = 0
print("BAD")
end

script.Parent.Touched:connect(Touched)
0
It's for a gamepass though, not a shirt. Though I see what you did, I'll try to change it myself to a gamepass and if I fail I'll let you know, thanks for your help, it's very much apprectiated! :D Xeron750 0 — 10y
0
No problem, also its a simple thing. Its like a VIP Door. Go get one from free models and edit it's script. Play around with free modeled scripts to learn. RolandStudio 115 — 10y
0
Ok, thanks! :) By the way I couldn't get this one to work, I couldn't figure out how to make the t-shirt into a gamepass ID. Xeron750 0 — 10y
Ad

Answer this question