Whenever I pickup my tool everything lags, here is what I mean:
https://gyazo.com/ea95c5e6c377083d1a210311139cc9af
The 2 errors I’m getting:
Workspace.trainmaster_65.EventHandler:31: attempt to index nil with ‘Hitbox’
Workspace.trainmaster_65.EventHandler:16: attempt to index nil with ‘Triggered’
The Script:
local RS = game:GetService("ReplicatedStorage")
local TS = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")
local RunS = game:GetService("RunService")
local Players = game:GetService("Players")
local localPlayers = game:GetService("Players").LocalPlayer
local Char = script.Parent
--//DropPickupClient//--
RunS.RenderStepped:Connect(function()
for i, Drop in pairs(game.Workspace.ItemLocations.Dropped:GetChildren()) do
if Drop.ClassName ~= "LocalScript" then
local TargetProximityPrompt = Drop:FindFirstChild("Handle"):FindFirstChildWhichIsA("ProximityPrompt")
TargetProximityPrompt.Triggered:Connect(function(player)
TS:Create(TargetProximityPrompt.Parent.Hitbox.Highlight, TweenInfo.new(.25, Enum.EasingStyle.Circular), {FillTransparency = 1}):Play()
script:WaitForChild("Search"):Play()
end)
TargetProximityPrompt.PromptShown:Connect(function(prompt)
script:WaitForChild("PromptVisibleUI"):Play()
TS:Create(TargetProximityPrompt.Parent.Hitbox.Highlight, TweenInfo.new(.25, Enum.EasingStyle.Circular), {FillTransparency = 0.5}):Play()
end)
TargetProximityPrompt.PromptHidden:Connect(function(prompt)
--script:WaitForChild("PromptVisibleUI"):Play()
TS:Create(TargetProximityPrompt.Parent.Hitbox.Highlight, TweenInfo.new(1, Enum.EasingStyle.Circular), {FillTransparency = 1}):Play()
end)
end
end
end)
Now I do know the reason, it’s because of the renderstep, but without it the highlights won’t appear. What do I do??