hi, my problem the adornee of the billboardgui stays and doesn’t give the ‘nil’ property as it’s supposed to be going
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Player = game:GetService('Players').LocalPlayer
local UIS = game:GetService('UserInputService')
local RunService = game:GetService('RunService')
local Humanoid = Player.Character:WaitForChild('HumanoidRootPart')
local RemoteEvents = ReplicatedStorage:WaitForChild('RemoteEvents')
local MyAction = ReplicatedStorage:WaitForChild('MyAction')
local RobEvent = RemoteEvents:WaitForChild('RobEvent')
local InteractionGui = MyAction:WaitForChild('EFloat'):Clone()
InteractionGui.Parent = Player.PlayerGui
local Rob = workspace:WaitForChild('Rob')
local RobbableParts = {}
for _,v in ipairs(Rob:GetChildren()) do
if v.Name == 'RobPart' then
table.insert(RobbableParts, v)
end
end
local function CheckDistance(Object, Distance)
local Mag = (Humanoid.Position - Object.Position).Magnitude
if Mag < Distance then
return true
end
end
local CanRob = true
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
local Pressed = input.KeyCode
if Pressed == Enum.KeyCode.E and not gameProcessedEvent then
for i,RobPart in ipairs(RobbableParts) do
if CheckDistance(RobPart, 15) then
if CanRob then
CanRob = false
RobEvent:FireServer(RobPart.MoneyInside.Value, true)
end
wait(600) -- Waiting 10 minutes cooldown
CanRob = true
end
end
end
end)
RunService.RenderStepped:Connect(function()
local CloseInteractionsList = {}
for _,v in ipairs(RobbableParts) do
if CheckDistance(v, 15) then
table.insert(CloseInteractionsList, v)
if #CloseInteractionsList >= 1 then
InteractionGui.Adornee = CloseInteractionsList[1]
InteractionGui.Enabled = true
else
table.remove(CloseInteractionsList, v)
InteractionGui.Adornee = nil
InteractionGui.Enabled = false
end
end
wait()
end
end)