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

Why Wont This Script Work?

Asked by
Benqazx 108
8 years ago
local loc = 50
local target = script.Parent.TargetPlayer.Value
repeat wait()
until(target:FindFirstChild("Torso").Position - target:FindFirstChild("Humanoid"):FindFirstChild("Soldier").Torso.Position).magnitude > loc
    script.Parent.Stars2.Disabled = false
    script.Parent.NonActive.Disabled = true
    script.Parent.Active.Disabled = false
    script.Disabled = true

this script goes into a NPC. so basically i want the stars2 script and the Active script to be enabled when the NPC is 50 studs away from a player. this script will not work for some reason. in the output the error is 13:31:54.557 - Workspace.Player1.Humanoid.Player1's Cop.Stars:4: attempt to index a nil value 13:31:54.558 - Stack Begin 13:31:54.558 - Script 'Workspace.Player1.Humanoid.Player1's Cop.Stars', Line 4 13:31:54.559 - Stack End the value i used is object value i have checked the value it has the players name in there.

1
until target:FindFirstChild("Torso") and target:FindFirstChild("Humanoid") remove the rest and that should fix it. Hero_ic 502 — 8y
0
its not if the humanoid is nil or not i want it so that if the distance of target and the soilder is higher the 50 then the Active script and the Stars2 script will be enabled Benqazx 108 — 8y
0
i changed it and it is working now. ty for the help Benqazx 108 — 8y

Answer this question