Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Unexpected error in my script?

Asked by 10 years ago
while targetfound == false do
    for i, v in pairs(Workspace:GetChildren()) do
        if v:FindFirstChild("Target") ~= nil then
            target = v -- line 48
            print("target")
            if (script.Parent.Position - target.Position).magnitude < range then
                print("in range")               
                targetfound = true
                print("TargetfoundMG == "..tostring(targetfound))
                repeat
                    move(target)
                    print("fire")
                    fire(target)
                    wait(5)
                until
                    target == nil or (script.Parent.Position - target.Position).magnitude > range   
                    print("target lost")
                    targetfound = false 
                    print("TargetfoundMG == "..tostring(targetfound))
            end
        end
    end
    wait(.5)
end 

This is a snippet from a target finding system (sorta obvious) in this case it is trying to find a string value named "Target" that has the value "Target" this is the error I get

"23:33:45.046 - Position is not a valid member of StringValue 23:33:45.047 - Script 'Workspace.MG Turret.Rocket.MGFire', Line 48 23:33:45.047 - Stack End"

If you feel trusting enough to open a link, here's the hierarchy of the part: http://prntscr.com/3jmpnw if not then I'll try to explain it Follower (a part) Health (number value) Target (the string value) BodyPosition Script (to make the bodyposition follow my character for testing purposes)

I'm sorry if I haven't thoroughly explained, it's just that I have no clue why this is happening.

(Edited to include the whole target finding script)

2
That code snippit has nothing to do with the error DragonSkyye 517 — 10y
1
coltn's right. What's on the next line? Also, `v:FindFirstChild("Target").Parent` equates to just `v`. adark 5487 — 10y
0
Ok, I was just really confused about how that line was doing anything with a position. LightArceus 110 — 10y
0
I added the rest of the target finder. LightArceus 110 — 10y

Answer this question