Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

6 comments

0

I've attempted an estimated 15 times to make this work.

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.

0

Oh yeah I forgot about that

0

Thank Line 9 and 14 on both scripts seems to be the problem.

0

Could you help me find the problem?

0

It says Disconnected Event Because Of Expectation aswell.

2 answers

✓ Accepted answer

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.

4 comments

0

I accidently posted the same script twice on the pot sorry about that.

0

if v:lower() == name:lower then Is underlined red

0

if v:lower() == name:lower(). You missed the open and close parentheses on the second lower.

0

Golden is correct, my bad.

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.