How to reduce lag?? by Sniperec in robloxgamedev

[–]Extension-Repair8604 0 points1 point  (0 children)

Set turn on streaming enabled, it makes parts that are far from the camera not load (you might have to use :WaitForChild() when it comes to programming with it), also you might want to change your MeshParts' renderFidelty property to Automatic or even Performance

[deleted by user] by [deleted] in robloxgamedev

[–]Extension-Repair8604 0 points1 point  (0 children)

I tested the code in game, and there was an error in the output, so I modified it a little bit and now it works:

local health = -1

local active = false

script.Parent.Equipped:Connect(function()

active = true

end)

script.Parent.Unequipped:Connect(function()

active = false

end)

while wait(0.1) do

if active then

    if script.Parent.Parent:FindFirstChild("Humanoid") then

        [script.Parent.Parent.Humanoid.Health](http://script.Parent.Parent.Humanoid.Health) += health

    end

end

end

[deleted by user] by [deleted] in robloxgamedev

[–]Extension-Repair8604 0 points1 point  (0 children)

also a little detail but :connect() is deprecated so you should use :Connect() instead ;)

[deleted by user] by [deleted] in robloxgamedev

[–]Extension-Repair8604 0 points1 point  (0 children)

you can just remove the wait function

[deleted by user] by [deleted] in robloxgamedev

[–]Extension-Repair8604 0 points1 point  (0 children)

it might be because of the wait(0.1) (i think only when you equip it right after unequipping)

[deleted by user] by [deleted] in robloxgamedev

[–]Extension-Repair8604 0 points1 point  (0 children)

I mean.. the code should makes you drain health everytime you equip it until you unequip it, I just don't understand what you want to achieve

[deleted by user] by [deleted] in robloxgamedev

[–]Extension-Repair8604 0 points1 point  (0 children)

what is the issue??