So i dont have a very good explaination but ill explain how i can so
Glitch.rbxm (10.2 KB)
this model of mine is a press E to equip tool but when there are more than 1 tool in workspace and i go near a tool the script starts to glitch out (you can see it by dowloading the model and dragging it in roblox studio) and another problem is when i walk over 2 or more tools and when i am on a tool and i click E all the tools that i previously walked on get parented to my backpack why is it happening please tell me thank you
this is my press e to equip local script and yes i only used local scripts i know i can use server script but rn i am using local
local plr = game.Players.LocalPlayer
local gui = script.Parent.Parent
local char = plr.Character or plr.CharacterAdded:Wait()
game:GetService("RunService").RenderStepped:Connect(function()
for i,v in pairs(game.Workspace:GetDescendants()) do
if v:IsA("Tool") then
if (v.Handle.Position - char.PrimaryPart.Position).Magnitude <= 5 then
if gui.Size ~= UDim2.new(1,0,1,0) then
if v.Parent ~= char then
gui.Adornee = v.Handle
gui.Enabled = true
gui.Back:TweenSize(UDim2.new(1,0,1,0),"Out","Sine",0.1)
end
game:GetService("UserInputService").InputBegan:Connect(function(i)
if i.KeyCode == Enum.KeyCode.E then
gui.Back:TweenSize(UDim2.new(0,0,0,0),"Out","Sine",0.1)
wait(0.1)
gui.Adornee = nil
gui.Enabled = false
v.Parent = plr.Backpack
end
end)
end
else
gui.Back:TweenSize(UDim2.new(0,0,0,0),"Out","Sine",0.1)
wait(0.1)
gui.Adornee = nil
gui.Enabled = false
end
end
end
end)