So I have a tool out in the workspace, and noticed that it gets cloned into the players character when its picked up (not the backpack) I'm not sure why this happens but I went with it and created this script.
It works fine in solo but not online. Anyone know why?
while true do
wait(.1)
local plr = game.Players.LocalPlayer
local player = plr.Name
local PlayerInventory = game.Workspace:FindFirstChild(player)
local val = script.Parent.Value.Value
local ObjFrame = plr.PlayerGui.Objectives.Frame
if PlayerInventory:FindFirstChild("Flashlight") and val == 1 and ObjFrame.Visible == true then -- error is that PlayerInventory is a nil value
-- The rest of this script was just added to this code block for completion
val = 0
ObjFrame.Objective.Text = "Objective Complete"
ObjFrame.Flavour.Text = ""
for i = 1,200,5 do
ObjFrame.Objective.TextColor3 = Color3.new (1-i/255,1,1-i/255)
wait()
end
wait(4)
for i = 1,100,2 do
ObjFrame.Flavour.TextTransparency = i/100
ObjFrame.Objective.TextTransparency = i/100
ObjFrame.TextLabel.TextTransparency = i/100
wait()
end
ObjFrame.Visible = false
ObjFrame.Flavour.TextTransparency = 1
ObjFrame.Objective.TextTransparency = 1
ObjFrame.TextLabel.TextTransparency = 1
ObjFrame.Objective.TextColor3 = Color3.new (0, 0,0)
end
end
