hi, just a question.
im making a randomizer and im worried that a player that constantly unequip-equipping items at a rapid pace will make the server somewhat laggy and i dont want that. do you guys have any tips/ways for me to stop / defend against that?
here’s my script (it is local script)
ContextActionService.LocalToolEquipped:Connect(function(toolinstance)
local ToolInstanceData = toolinstance:WaitForChild("Data")
local ToolSkills = ToolInstanceData:WaitForChild("Skills")
local Skill1 = ToolSkills:FindFirstChild("Skill1") or nil
local Skill2 = ToolSkills:FindFirstChild("Skill2") or nil
SkillBinds.Visible = true
if Skill1 then
local function ActivateSkill1(actionname,inputstate)
if inputstate == Enum.UserInputState.Begin then
Skill1:FireServer()
end
end
ContextActionService:BindAction("ESkill",ActivateSkill1,true,Enum.KeyCode.E)
firstSkillgui.Visible = true
firstSkillName.Text = if Skill1:GetAttribute("CustomName") then Skill1:GetAttribute("CustomName") else Skill1.Name
else
firstSkillgui.Visible = false
end
--
if Skill2 then
local function ActivateSkill2(actionname,inputstate)
if inputstate == Enum.UserInputState.Begin then
Skill2:FireServer()
end
end
ContextActionService:BindAction("RSkill",ActivateSkill2,true,Enum.KeyCode.R)
secondSkillgui.Visible = true
secondSkillName.Text = if Skill2:GetAttribute("CustomName") then Skill2:GetAttribute("CustomName") else Skill2.Name
else
secondSkillgui.Visible = false
end
end)
ContextActionService.LocalToolUnequipped:Connect(function(instance)
ContextActionService:UnbindAction("ESkill")
ContextActionService:UnbindAction("RSkill")
SkillBinds.Visible = false
end)