My If statement won’t run. In the console it says…
Players.Seeker4050.PlayerScripts.LocalScript:10: attempt to index nil with 'arent'
Here is the source code.
10. if Hit.Parent.Configuration.Class.Value == "Tree" then
Here is the entire code.
1. -- Seeker4050
2. -- Data --
3. local StarterGui = game.StarterGui -- Grabs the StarterGui
4. local Info = StarterGui.ScreenGui["Info Channel"] -- Grabs the Info Text
5. local Player = game.Players.LocalPlayer
6. local Mouse = Player:GetMouse() -- Get the Mouse
7. -- Main --
8. Mouse.Button1Down:Connect(function(Hit)
9.
10. if Hit.Parent.Configuration.Class.Value == "Tree" then -- Check if an objects Class in config is Tree
11.
12. local Tree = Hit.Parent -- Get the Tree
13.
14. Info.Text = Tree.Name .. " - " .. Tree.Configuration.Health.Value -- Set Info Text to the info in Configuration
15.
16. Info.Visible = true -- Set the Info Visible
17.
18. end
19.
20. end)
It displayed true. Here is the console and the Scripts Added.
09:33:59.781 Tree Target Found. - Client - LocalScript:18
09:33:59.781 Info Visible! - Client - LocalScript:26
Script:
1. – Seeker4050
2. -- Data --
3. local StarterGui = game.StarterGui -- Grabs the StarterGui
4. local Info = StarterGui.ScreenGui["Info Channel"] -- Grabs the Info Text
5. local Player = game.Players.LocalPlayer
6. local Mouse = Player:GetMouse() -- Get the Mouse
7. -- Main --
8. Mouse.Button1Down:Connect(function()
9.
10. if Mouse.Target.Parent.Configuration.Class.Value == "Tree" then -- Check if an objects Class in config is Tree
11.
12. print("Tree Target Found.")
13.
14. local Tree = Mouse.Target.Parent -- Get the Tree
15.
16. Info.Text = Tree.Name .. " - " .. Tree.Configuration.Health.Value -- Set Info Text to the info in Configuration
17.
18. Info.Visible = true -- Set the Info Visible
19.
20. print("Info Visible!")
21.
22. end
23.
24. end)