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

My Holo Commands are only working once, why is it?

Asked by 10 years ago

I made two serperate scripts, because then it only worked. The commands only work once. I need serious help.

Script One (Open Lobby)

01--DO NOT CHANGE!!!
02 
03local isAdmin = {["bosswalrus"] = true, ["BrockHCCS"] = true, ["mac3na3na"] = true, ["ultimatedeathwolf"] = true, ["BJL008"] = true, ["bealot"] = true}
04 
05--Open Lobby Function
06function onChatted(message, player)
07    --Open Lobby
08    if message == "open/lobby" and isAdmin[player.Name] then
09        game.Workspace.LobbyDoor.LobbyDoorPart.Transparency = 1
10        game.Worksapce.LobbyDoor.LobbyDoorPart.CanCollide = false
11     end
12end
13 
14game.Players.PlayerAdded:connect(function(player)
15    player.Chatted:connect(function(message) onChatted(message, player) end)
16end)

Script Two (Close Lobby)

01--DO NOT CHANGE!!!
02local isAdmin = {["bosswalrus"] = true, ["BrockHCCS"] = true, ["mac3na3na"] = true, ["ultimatedeathwolf"] = true, ["BJL008"] = true, ["bealot"] = true}
03 
04--Open Lobby Function
05function onChatted(message, player)
06    --Open Lobby
07    if message == "close/lobby" and isAdmin[player.Name] then
08        game.Workspace.LobbyDoor.LobbyDoorPart.Transparency = 0
09        game.Worksapce.LobbyDoor.LobbyDoorPart.CanCollide = true
10     end
11end
12 
13game.Players.PlayerAdded:connect(function(player)
14    player.Chatted:connect(function(message) onChatted(message, player) end)
15end)

The commands only work once. I need serious help.

0
I've attempted an estimated 15 times to make this work. BosswalrusTheCoder 88 — 10y
1
It may be stack-ending somewhere. Check the in-game Output (console) by pressing F9 in game, then click Server Console, it will tell you any errors in your code. Tempestatem 884 — 10y
0
Oh yeah I forgot about that BosswalrusTheCoder 88 — 10y
0
Thank Line 9 and 14 on both scripts seems to be the problem. BosswalrusTheCoder 88 — 10y
View all comments (2 more)
0
Could you help me find the problem? BosswalrusTheCoder 88 — 10y
0
It says Disconnected Event Because Of Expectation aswell. BosswalrusTheCoder 88 — 10y

2 answers

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Well, your two scripts are exactly the same... They both open the door. You need to make one of them set the Transparency to 0 and the Can Collide to true, and also change the command for one, like "close/lobby" or something. You can also use just one script and use an elseif. So,

1if message == "open/lobby" and isAdmin[player.Name] then
2    game.Workspace.LobbyDoor.LobbyDoorPart.Transparency = 1
3    game.Worksapce.LobbyDoor.LobbyDoorPart.CanCollide = false
4elseif message == "close/lobby" and isAdmin[player.Name] then
5    game.Workspace.LobbyDoor.LobbyDoorPart.Transparency = 0
6    game.Worksapce.LobbyDoor.LobbyDoorPart.CanCollide = true
7end

I think this would make your code work, but it's still kind of ugly. Here's how I do my holo scripts:

01local admins = {"bob","jeff","john","joe"}
02 
03function isAdmin(name)
04    for i,v in pairs(admins) do
05        if v:lower() == name:lower() then
06            return true
07        end
08    end
09    return false
10end
11 
12game.Players.PlayerAdded:connect(function(plr)
13    if isAdmin(plr.Name) then
14        plr.Chatted:connect(function(msg)
15            --stuff
16        end)
17    end
18end)

It's really your choice though. I have a holo script in my models if you want to study it.

0
I accidently posted the same script twice on the pot sorry about that. BosswalrusTheCoder 88 — 10y
0
if v:lower() == name:lower then Is underlined red BosswalrusTheCoder 88 — 10y
0
if v:lower() == name:lower(). You missed the open and close parentheses on the second lower. GoldenPhysics 474 — 10y
0
Golden is correct, my bad. Perci1 4988 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

local isAdmin = {"bosswalrus", "BrockHCCS", "mac3na3na", "ultimatedeathwolf", "BJL008","bealot"} local firstl = ":" --Set to something you want like :openl or c/openl

function checkadmin(name) for _,v in pairs(isAdmin) do if name:lower() == isAdmin:lower() then return true end end return false end

game.Players.PlayerAdded:connect(function(plr) if checkadmin(plr.Name) then plr.Chatted:connect(function(msg) if msg:lower():sub(2,7) == "closel" and msg:sub(1,1) == firstl then game.Workspace.LobbyDoor.LobbyDoorPart.Transparency = 0 game.Worksapce.LobbyDoor.LobbyDoorPart.CanCollide = true end if msg:lower():sub(2,6) == "openl" and msg:sub(1,1) == first then game.Workspace.LobbyDoor.LobbyDoorPart.Transparency = 1 game.Worksapce.LobbyDoor.LobbyDoorPart.CanCollide = false end end)

Answer this question