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

My script won't work help please?

Asked by
Rdite 30
9 years ago

I want it so when the value Hidden that is located inside the player when the value equals 1 you can't be killed because your hidden it all works except the killing bit..

local self = script.Parent
local light = Instance.new("SpotLight",self)
local config = self:WaitForChild("Configuration")

local function registerValue(v)
light[v.Name] = v.Value
v.Changed:connect(function ()
light[v.Name] = v.Value
end)
end

for _,v in pairs(config:GetChildren()) do
registerValue(v)
end

config.ChildAdded:connect(registerValue)

function isInSpotLight(spotLight,position)
local cone = math.rad(spotLight.Angle)
local part = spotLight.Parent
local direction = CFrame.new(part.Position, (part.CFrame * CFrame.new(Vector3.FromNormalId(spotLight.Face))).p)
local space = direction:pointToObjectSpace(position)
local unit = space.unit
return (unit.Z < 0) and (unit.X > (cone/-2) and unit.X < (cone/2)) and (space.magnitude <= spotLight.Range)
end

while wait(0.2) do
local isIn = false
for _,v in pairs(game.Players:GetPlayers()) do
if v.Character then
local torso = v.Character:findFirstChild("Torso")
if torso then
if isInSpotLight(light,torso.Position) then
if torso.Parent.Hidden.Value == 0 then
torso.Parent.Humanoid.Health = 0
isIn = true
break
end
end
end
end
end
end`

I need the killing bit fixed please.

if isInSpotLight(light,torso.Position) then
if torso.Parent.Hidden.Value == 0 then -- Hidden if you can be killed
torso.Parent.Humanoid.Health = 0
isIn = true`

Answer this question