Hello everyone, I am making a deployable ladder system where you point the mouse too. Im looping a part of the code that maked the ladder preview follow the mouse. For some reason, and this has started happening some days ago since it happens too with a turret I have that uses a similar system to point the mesh to the mouse, it causes lag.
This is the script I am using currently:
local tool = script.Parent
local previews = workspace.Previews
local one = previews.PStage1
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local equipped
tool.Equipped:Connect(function(mouse)
print("Weapon equipped")
equipped = true
while wait(0.1) and equipped == true do
print("Loop")
one.CFrame = CFrame.new(mouse.Hit.Position)
one.Transparency = 0.7
end
end)
tool.Unequipped:Connect(function(mouse)
print("Weapon unequipped")
equipped = false
one.Transparency = 1
end)
Thanks for reading, I hope there is a simple solution for this.