GroupId = 290188 MinimumRank = 25 function onChatted(msg,player) if player:GetRankInGroup(GroupId) >= MinimumRank then if msg:sub(1,5) == "!Host" then player.TeamColor = BrickColor.new("Eggplant") player:LoadCharacter() end end
How does the script know that the variable/argument "player" is the LocalPlayer?
It doesn't.
Since Roblox, at the time of this post, broke the PlayerAdded event in Play Solo mode. You will need to add a for loop at the bottom of the script to loop through all players and connect them to the PlayerAdded event. This is so you may test the script properly in play solo mode.
Also, when dealing with commands, make the chat and command the same case (as in upper or lower case). Otherwise, it might annoy the heck out of the user for not having the correct capitalization of a command.
GroupId = 290188 MinimumRank = 25 function onChatted(msg,player) if player:GetRankInGroup(GroupId) >= MinimumRank then if msg:sub(1,5):lower() == "!host" then --Just add :lower() to the end of the string to make whatever they say lowercase to the script. This way commands are not case sensitive. player.TeamColor = BrickColor.new("Eggplant") player:LoadCharacter() end --That third end you forgot. end end function PlayerAdded(player) --Player is given to us by the PlayerAdded event. It's the physical player object that will be used. player.Chatted:connect(function(Chat) --.Chatted is an event of a player. Every time they chat, it goes through this event. This is an anonymous function. It's not exactly a function we can call, more of the function we are using. Chat is our string that the player has said. onChatted(Chat, player) --Now we are calling the function Chat being msg to the OnChatted function, and player being player to the function. end) --Annonymous functions have an end with a ) to show the end of the connect function. end game.Players.PlayerAdded:connect(PlayerAdded) for _,player in pairs(game.Players:GetPlayers()) do --For every player in Players service, do something. PlayerAdded(player) --Alright, we'll add them to the function we created. end
GroupId = 290188 MinimumRank = 25 ---------------------------------------------------- ------------------------------------------------------ function onChatted(msg,player) if player:GetRankInGroup(GroupId) >= MinimumRank then if msg:sub(1, 8):lower() == "!poweron" then game.Lighting.FogEnd = 1000000 wait(2) game.Lighting.Brightness = 100 wait(3) game.Workspace.Stairs.Stair.BrickColor = BrickColor.Yellow() wait(0.3) ------------------------------------------------------------------------ game.Workspace.Stairs2.Stair.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs2.Model2.Stair2.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs2.Model2.Stair25.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs2.Model.Stair3.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs2.Model.Stair35.BrickColor = BrickColor.Yellow() wait(0.3) ------------------------------------------------------------------------- game.Workspace.Stairs5.Model2.Stair2.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs5.Model2.Stair25.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs5.Stair.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs5.Model.Stair3.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs5.Model.Stair35.BrickColor = BrickColor.Yellow() wait(0.3) ------------------------------------------------------------------------ game.Workspace.Stairs3.Stair.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs3.Model2.Stair2.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs3.Model2.Stair25.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs3.Model.Stair3.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Stairs3.Model.Stair35.BrickColor = BrickColor.Yellow() wait(0.3) ------------------------------------------------------------------------ -----------------------------END OF STAIRS------------------------------ game.Workspace.Line.Line1.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Line.Line2.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Line.Line3.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.Line.Line4.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.SideLines.Part1.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.SideLines.Part2.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.SideLines.Part3.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.SideLines.Part4.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.SideLines.Part5.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.SideLines.Part6.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.SideLines.Part7.BrickColor = BrickColor.Yellow() wait(0.3) game.Workspace.SideLines.Part8.BrickColor = BrickColor.Yellow() wait(0.3) --------------------------------------END OF LINES------------------------------------------------ --------------------------------------END OF POWER ON--------------------------------------------- end end if msg:sub(1,5):lower() == "!host" then player.TeamColor = BrickColor.new("Eggplant") player:LoadCharacter() game.Lighting.Host:Clone().Parent = player.PlayerGui wait(5) player.PlayerGui.Host:Remove() end end game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(message) onChatted(message, player) end) end)