local groupId = 123456
local adminRank = 9
local timer = 3 -
local typespeed = 0.05
local textlabel = game.Workspace.Rulesboard.RulesBoard.SurfaceGui.Rules
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RulesEvent")
local remoteEvent2 = ReplicatedStorage:WaitForChild("RulesEvent2")
local function typewrite(object,text)
for i = 1,#text,1 do
object.Text = string.sub(text,1,i)
wait(typespeed)
end
end
function onChatted(msg, speaker)
if speaker:GetRankInGroup(groupId) >= adminRank then
local source = string.lower(speaker.Name)
msg = string.lower(msg)
if string.find(msg, "!rules") then
remoteEvent:FireAllClients()
wait(1)
typewrite(textlabel,"Hey there! Welcome to Embassy's Training Centre. Before we begin, there are some rules you must be aware of.")
wait(timer)
typewrite(textlabel,"Please ensure that you are listening to your trainer's instructions through out the session.")
wait(timer)
typewrite(textlabel,"If you're planning to idle or afk, notify your trainer. You do not want to be falsely removed from the training session.")
wait(timer)
typewrite(textlabel,"Please make sure that you use flawless grammar to the best of your potential, as it is important in getting good results.")
wait(timer)
typewrite(textlabel,"If you have any questions, feel free to ask a trainer. Do not ask the host or co-host.")
wait(timer)
typewrite(textlabel,"Do not leave until you have been kicked by a high rank. Otherwise, you may not receive your rank.")
wait(timer)
typewrite(textlabel,"If you are seen roaming around freely without permission, you will be removed from the training session.")
wait(timer)
typewrite(textlabel,"We are now prepared. Please follow your respective trainers into the training rooms. Good luck trainees!")
wait(timer)
remoteEvent2:FireAllClients()
else
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:connect(function(msg)onChatted(msg, player) end)
end)
you’re most likely running into a memory leak because of the constant wait() spam on the server side, a far more efficient method would be to make the entire rule function handled by the client after the RulesEvent remote is fired
you can simply move the entire rule listing function into the remote’s OnClientEvent function, which I assume is the function responsible for making the surfacegui visible & it should work as intended
It seems to be working, but the camera isn’t positioned. I believe it runs the first RemoteEvent and then right after the second one that takes it off. Do you know how this could be fixable? https://gyazo.com/4e4e759b9f988e380d014c278ba4eb5b
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RulesEvent")
local function onRulesCmd()
local textlabel = game.Workspace.Rulesboard.RulesBoard.RulesGUI.Rules
local timer = 3 -- Seconds until slide changes
local typespeed = 0.05 -- The speed the typing is done at
local function typewrite(object,text)
for i = 1,#text,1 do
object.Text = string.sub(text,1,i)
wait(typespeed)
end
end
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CameraSubject = workspace.Rulesboard.CameraPart
workspace.CurrentCamera.CFrame = workspace.Rulesboard.CameraPart.CFrame
wait(1)
typewrite(textlabel,"Hey there! Welcome to Embassy's Training Centre. Before we begin, there are some rules you must be aware of.")
wait(timer)
typewrite(textlabel,"Please ensure that you are listening to your trainer's instructions through out the session.")
wait(timer)
typewrite(textlabel,"If you're planning to idle or afk, notify your trainer. You do not want to be falsely removed from the training session.")
wait(timer)
typewrite(textlabel,"Please make sure that you use flawless grammar to the best of your potential, as it is important in getting good results.")
wait(timer)
typewrite(textlabel,"If you have any questions, feel free to ask a trainer. Do not ask the host or co-host.")
wait(timer)
typewrite(textlabel,"Do not leave until you have been kicked by a high rank. Otherwise, you may not receive your rank.")
wait(timer)
typewrite(textlabel,"If you are seen roaming around freely without permission, you will be removed from the training session.")
wait(timer)
typewrite(textlabel,"We are now prepared. Please follow your respective trainers into the training rooms. Good luck trainees!")
wait(timer)
typewrite(textlabel," ")
end
remoteEvent.OnClientEvent:Connect(onRulesCmd)
Second:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RulesEvent2")
local function offRulesCmd()
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end
remoteEvent.OnClientEvent:Connect(offRulesCmd)