ViperJ1
|
  |
| Joined: 27 Nov 2012 |
| Total Posts: 9 |
|
|
| 24 Jan 2013 08:25 PM |
Hello,
So I've been trying for 2 days to get this to work. I'm new to scripting obviously. I finally made the vip door kill however it only works once. I dont know how to get it to continue to kill after I respawn and try to get in. I'm at a total loss. Any help out there?
I commented the part that I added so it's easier for you to see what I messed up.
local door = script.Parent function open() -- This function will open the door. door.CanCollide = false -- Make players able to walk through the door. for transparency = 0, 1, .1 do door.Transparency = transparency wait(.1) end end function close() -- This function will close the door. for transparency = 1, 0, -.1 do door.Transparency = transparency wait(.1) end door.CanCollide = true -- Make players unable to walk through the door. end -- This function returns the player a certain part belongs to. function get_player(part) --iterate over each player for _, player in ipairs(game.Players:GetPlayers()) do --if the part is within the player's character if part:IsDescendantOf(player.Character) then --return the player return player end end end
door.Touched:connect(function(part) -- If it isn't a character that touched the door, then we ignore it. local human = part.Parent:findFirstChild("Humanoid")-- I ADDED THIS PART AND THE ELSE BELOW local player = get_player(part) if not player then return end local allow = ( player.Name == "" or player.Name == "" or player.Name == "" or player.Name == "" or player:IsInGroup(127081) and player:IsFriendsWith(game.CreatorId) or -- This demonstrates how you can use 'and' to combine two restrictions. game:GetService('BadgeService'):UserHasBadge(player.userId, 1032571) or game.CreatorId == player.userId ) if allow then open() delay(2, close) else -- I ADDED THIS PART TOO. human.Health = (0)
end end) |
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
|
| 24 Jan 2013 08:56 PM |
local door = script.Parent
function open() door.CanCollide = false for transparency = 0, 1, .1 do door.Transparency = transparency wait(.1) end end
function close() for transparency = 1, 0, -.1 do door.Transparency = transparency wait(.1) end door.CanCollide = true end
door.Touched:connect(function(part) human = part.Parent:findFirstChild("Humanoid") player = game.Players:GetPlayerFromCharacter(part.Parent) if human and player then
local allow = { player.Name == "person1" or player.Name == "person2" or player.Name == "person3" or player.Name == "person4" or player:IsInGroup(127081) and player:IsFriendsWith(game.CreatorId) or game:GetService('BadgeService'):UserHasBadge(player.userId, 1032571) or game.CreatorId == player.userId } for i,v in pairs (allow) do if v or then open() delay(2, close) else human:TakeDamage(human.MaxHealth) end end end)
Should work. |
|
|
| Report Abuse |
|
|
ViperJ1
|
  |
| Joined: 27 Nov 2012 |
| Total Posts: 9 |
|
|
| 25 Jan 2013 05:19 PM |
Thank you for your reply. I tried it and it doesn't work. It wont allow me through and it doesn't kill now either. I think there might be an issue with line 34 as the syntax has a red line under it but i dont know how to fix it. line 34 is this part
if v or then
any ideas? |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2013 05:30 PM |
Not how tables work, anywho this might work, though i didn't recount the ends.
local door = script.Parent
function open() door.CanCollide = false for transparency = 0, 1, .1 do door.Transparency = transparency wait(.1) end end
function close() for transparency = 1, 0, -.1 do door.Transparency = transparency wait(.1) end door.CanCollide = true end
door.Touched:connect(function(part) human = part.Parent:findFirstChild("Humanoid") player = game.Players:GetPlayerFromCharacter(part.Parent) if human and player then
local allow = {"player1","Player2","ect..."}
for i,v in pairs (allow) do if player.Name == v or player:IsInGroup(127081) and player:IsFriendsWith(game.CreatorId) or game:GetService('BadgeService'):UserHasBadge(player.userId, 1032571) or game.CreatorId == player.userIdthen then -- my lerd... open() delay(2, close) else human:TakeDamage(human.MaxHealth) end end end) |
|
|
| Report Abuse |
|
|
ViperJ1
|
  |
| Joined: 27 Nov 2012 |
| Total Posts: 9 |
|
|
| 25 Jan 2013 06:18 PM |
| Thank you but that also produced nothing. It doesn't open or close the door or kill. hmm... |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2013 06:22 PM |
local allow={"Person","more people","just follow this syntax..."} for _,v in pairs(allow)do allow[v]=true end local door = script.Parent function open() door.CanCollide = false for transparency = 0, 1, .1 do door.Transparency = transparency wait(.1) end end function close() for transparency = 1, 0, -.1 do door.Transparency = transparency wait(.1) end door.CanCollide = true end door.Touched:connect(function(part) human = part.Parent:findFirstChild("Humanoid") player = game.Players:GetPlayerFromCharacter(part.Parent) if human and player then if allow[part.Parent.Name]or player:IsInGroup(127081) and player:IsFriendsWith(game.CreatorId) or game:GetService('BadgeService'):UserHasBadge(player.userId, 1032571) or game.CreatorId == player.userIdthen then open() delay(2,function()close()end) else part.Parent:BreakJoints() end end end) |
|
|
| Report Abuse |
|
|
ViperJ1
|
  |
| Joined: 27 Nov 2012 |
| Total Posts: 9 |
|
|
| 25 Jan 2013 06:40 PM |
@woodstauk4
yours will open the door for permitted players but it's not killing the ones not permitted. I tried setting the health to 0 also and that did nothing. I appreciate all the help. The script on my original post works the best but it only works once then wont kill again. Does anyone know why that might be?
|
|
|
| Report Abuse |
|
|
|
| 25 Jan 2013 06:47 PM |
The problem is your combination of 'or' and 'and' statements.
local allow={"Person","more people","just follow this syntax..."} for _,v in pairs(allow)do allow[v]=true end local door = script.Parent function open() door.CanCollide = false for transparency = 0, 1, .1 do door.Transparency = transparency wait(.1) end end function close() for transparency = 1, 0, -.1 do door.Transparency = transparency wait(.1) end door.CanCollide = true end door.Touched:connect(function(part) human = part.Parent:findFirstChild("Humanoid") player = game.Players:GetPlayerFromCharacter(part.Parent) if human and player then if allow[part.Parent.Name]then open() delay(2,function()close()end) elseif player:IsInGroup(127081) and player:IsFriendsWith(game.CreatorId) then open() delay(2,function()close()end) elseif game:GetService('BadgeService'):UserHasBadge(player.userId, 1032571)then open() delay(2,function()close()end) elseif game.CreatorId == player.userIdthen then open() delay(2,function()close()end) else part.Parent:BreakJoints() end end end) |
|
|
| Report Abuse |
|
|
josh1159
|
  |
| Joined: 23 Jun 2008 |
| Total Posts: 5458 |
|
|
| 25 Jan 2013 07:03 PM |
local allow={"Person","more people","just follow this syntax..."} for _,v in pairs(allow)do allow[v]=true end local door = script.Parent function open() door.CanCollide = false for transparency = 0, 1, .1 do door.Transparency = transparency wait(.1) end end function close() for transparency = 1, 0, -.1 do door.Transparency = transparency wait(.1) end door.CanCollide = true end door.Touched:connect(function(part) human = part.Parent:findFirstChild("Humanoid") player = game.Players:GetPlayerFromCharacter(part.Parent) if human and player then if allow[part.Parent.Name]then open() delay(2,function()close()end) elseif player:IsInGroup(127081) and player:IsFriendsWith(game.CreatorId) then open() delay(2,function()close()end) elseif game:GetService('BadgeService'):UserHasBadge(player.userId, 1032571)then open() delay(2,function()close()end) elseif game.CreatorId == player.userIdthen then open() delay(2,function()close()end) else part.Parent:BreakJoints() end end end) |
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
|
| 25 Jan 2013 07:10 PM |
function open() door.CanCollide = false for transparency = 0, 1, .1 do door.Transparency = transparency wait(.1) end end
function close() for transparency = 1, 0, -.1 do door.Transparency = transparency wait(.1) end door.CanCollide = true end
door.Touched:connect(function(part) human = part.Parent:findFirstChild("Humanoid") player = game.Players:GetPlayerFromCharacter(part.Parent) if human and player then
local allow = { player.Name == "person1" or player.Name == "person2" or player.Name == "person3" or player.Name == "person4" or player:IsInGroup(127081) and player:IsFriendsWith(game.CreatorId) or game:GetService('BadgeService'):UserHasBadge(player.userId, 1032571) or game.CreatorId == player.userId } for i,v in pairs (allow) do if v then open() delay(2, close) else human:TakeDamage(human.MaxHealth) end end end) |
|
|
| Report Abuse |
|
|
ViperJ1
|
  |
| Joined: 27 Nov 2012 |
| Total Posts: 9 |
|
|
| 25 Jan 2013 07:24 PM |
Those didn't work either, same result.
This is the wiki for the door code. Everything works perfectly until I try to add a kill script.
http://wiki.roblox.com/index.php/Restricted_door
Can anyone figure out a way to add a kill script to this? I tried to follow what the author wrote in the kill section but I'm not skilled enough....I've failed :( |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2013 07:27 PM |
local allow={"Person","more people","just follow this syntax..."} for _,v in pairs(allow)do allow[v]=true end local door = script.Parent function open() door.CanCollide = false for transparency = 0, 1, .1 do door.Transparency = transparency wait(.1) end end function close() for transparency = 1, 0, -.1 do door.Transparency = transparency wait(.1) end door.CanCollide = true end door.Touched:connect(function(part) human = part.Parent:findFirstChild("Humanoid") player = game.Players:GetPlayerFromCharacter(part.Parent) if human and player then if allow[part.Parent.Name]or game.CreatorId==player.userId or game:GetService('BadgeService'):UserHasBadge(player.userId, 1032)then open() delay(2,function()close()end) elseif player:IsInGroup(127081) and player:IsFriendsWith(game.CreatorId) then open() delay(2,function()close()end) else part.Parent:BreakJoints() end end end)
ok |
|
|
| Report Abuse |
|
|
ViperJ1
|
  |
| Joined: 27 Nov 2012 |
| Total Posts: 9 |
|
|
| 25 Jan 2013 07:40 PM |
@woodstauk4
Thank you, that worked! What did you change that made it work?
Also, a big thank you to all the others who tried to help. This has been something really bugging me. |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2013 07:44 PM |
Well, when you say 'and' and 'or' in the same line, I don't know how the game engine interprets that...
like, local d=true local f=false local c=false if f and c or d and f and c then what does this mean?????????????????ok
so I split up the and's and the or's into two lines. |
|
|
| Report Abuse |
|
|
ViperJ1
|
  |
| Joined: 27 Nov 2012 |
| Total Posts: 9 |
|
|
| 25 Jan 2013 07:58 PM |
| ok, I see. I don't understand but I get what you mean...if that makes sense. Thanks again. |
|
|
| Report Abuse |
|
|