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)

--DO NOT CHANGE!!!

local isAdmin = {["bosswalrus"] = true, ["BrockHCCS"] = true, ["mac3na3na"] = true, ["ultimatedeathwolf"] = true, ["BJL008"] = true, ["bealot"] = true}

--Open Lobby Function
function onChatted(message, player)
    --Open Lobby
    if message == "open/lobby" and isAdmin[player.Name] then
        game.Workspace.LobbyDoor.LobbyDoorPart.Transparency = 1
        game.Worksapce.LobbyDoor.LobbyDoorPart.CanCollide = false
     end
end

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(message) onChatted(message, player) end)
end)

Script Two (Close Lobby)

--DO NOT CHANGE!!!
local isAdmin = {["bosswalrus"] = true, ["BrockHCCS"] = true, ["mac3na3na"] = true, ["ultimatedeathwolf"] = true, ["BJL008"] = true, ["bealot"] = true}

--Open Lobby Function
function onChatted(message, player)
    --Open Lobby
    if message == "close/lobby" and isAdmin[player.Name] then
        game.Workspace.LobbyDoor.LobbyDoorPart.Transparency = 0
        game.Worksapce.LobbyDoor.LobbyDoorPart.CanCollide = true
     end
end

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(message) onChatted(message, player) end)
end)

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,

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

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

local admins = {"bob","jeff","john","joe"}

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

game.Players.PlayerAdded:connect(function(plr)
    if isAdmin(plr.Name) then
        plr.Chatted:connect(function(msg)
            --stuff
        end)
    end
end)

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