Script:
local Players = game.Players:GetPlayers() local BodyVelocity = script.Parent.BodyVelocity repeat wait() Players = game.Players:GetPlayers() until #Players > 0 local Settings = script.Parent.Settings local Aiming = script.Parent.Aiming local Target = script.Parent.Target.Value wait(Settings.AimTime.Value) Aiming.Value = false script.Parent.Anchored = false script.Parent.BodyVelocity.Velocity = CFrame.new(-script.Parent.Position, -Target.Position).Position
Error:
Workspace.RockProjectile.Main:20: attempt to index nil with 'Position'
I'm pretty sure the issue here is that "Target" is a Value, though you didn't explain what Value in the Target object is.
Target is a value, you have to first convert it to Vector3.
local Players = game.Players:GetPlayers() local BodyVelocity = script.Parent.BodyVelocity repeat wait() Players = game.Players:GetPlayers() until #Players > 0 local Settings = script.Parent.Settings local Aiming = script.Parent.Aiming local Target = script.Parent.Target.Value wait(Settings.AimTime.Value) Aiming.Value = false script.Parent.Anchored = false script.Parent.BodyVelocity.Velocity = CFrame.new(-script.Parent.Position, -Vector3.new(game.Workspace[Target].Position))
Try this code. Edit: I understand better now try this.
Many people here are mistaking that "Position" doesn't exist. If you read it carefully, you can see that it says that you're taking "position" from something that doesn't exist.
What people think is happening:
local tab = {} print(tab.Position) -- position doesn't exist
What is actually happening:
local tab = nil print(tab.Position) -- you're getting position from a non existant value, or nil
Therefore
-script.Parent.Position -Target.Position
One of these are nil. Either script.Parent doesn't exist (highly unlikely) Or target.Value hasn't been assigned to yet.
Chances are, it's the latter.
Either Target.Value is nil or Target.Value is an object without a Position value.