PickupInfoGui.FtoPickup.Text = Obj.Name.." - "..Obj.Handle.Minutes.Value.." minutes"
elseif Obj.Name == "WoodSword" then
PickupInfoGui.FtoPickup.Text = "Premium Required to claim this item"
end
You should probably include a couple more sanity checks before confirming it to be valid:
print(Obj)
print(Obj.Handle)
print(Obj.Handle.Minutes) --Errors at this point maybe
print(Obj.Handle.Minutes.Value)
PickupInfoGui.FtoPickup.Text = Obj.Name.." - "..Obj.Handle.Minutes.Value.." minutes"
elseif Obj.Name == "WoodSword" then
PickupInfoGui.FtoPickup.Text = "Premium Required to claim this item"
end
local UIS = game:GetService("UserInputService")
local pickupkey = "F"
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PickupItem = ReplicatedStorage:WaitForChild("PickupItem")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local PlayerGui = player:WaitForChild("PlayerGui")
local PickupInfoGui = PlayerGui:WaitForChild("PickupInfoGui")
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Player = game:GetService("Players").LocalPlayer
local Distance = 10
local Folder = workspace.Items
game:GetService("RunService").RenderStepped:Connect(function()
for i,Obj in pairs(Folder:GetDescendants()) do
if Obj:IsA("Tool") then
if Player:DistanceFromCharacter(Obj.Handle.Position) < Distance then
PickupInfoGui.Adornee = Obj.Handle
PickupInfoGui.FtoPickup.Text = Obj.Name.." - "..Obj.Handle:FindFirstChild("Minutes").Value.." minutes"
elseif Obj.Name == "WoodSword" then
PickupInfoGui.FtoPickup.Text = "Premium Required to claim this item"
end
end
end
end)
Inside your loop, I’d recommend checking a couple more things before confirming the values:
game:GetService("RunService").RenderStepped:Connect(function()
for i,Obj in pairs(Folder:GetDescendants()) do
if Obj:IsA("Tool") and Obj.Handle and Obj.Handle:FindFirstChild("Minutes") then
if Player:DistanceFromCharacter(Obj.Handle.Position) < Distance then
PickupInfoGui.Adornee = Obj.Handle
PickupInfoGui.FtoPickup.Text = Obj.Name.." - "..Obj.Handle:FindFirstChild("Minutes").Value.." minutes"
elseif Obj.Name == "WoodSword" then
PickupInfoGui.FtoPickup.Text = "Premium Required to claim this item"
end
end
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
for i,Obj in pairs(Folder:GetDescendants()) do
if Obj:IsA("Tool") then
if Player:DistanceFromCharacter(Obj.Handle.Position) < Distance then
PickupInfoGui.Adornee = Obj.Handle
PickupInfoGui.FtoPickup.Text = Obj.Name.." - "..Obj.Handle.Minutes.Value.." minutes"
end
if not Obj.Handle:FindFirstChild("Minutes") then
if Obj.Name == "WoodSword" then
PickupInfoGui.FtoPickup.Text = "Premium Required to claim this item"
end
end
end
end
end)