Script is not working in different place

I tried to use this script in a different place and it stops working after reset… how is it possible ???
LocalScriptдшпре.rbxm (3.4 KB)

another place
image
original place
image

i opened an explorer while playtesting my game and the pointlight is there, but it says PointLighthhh is not a valid member of LocalScript "Players.SpynApple_P.Backpack.LocalScript"

image

can we see the script that shows this error?

local mouse = game.Players.LocalPlayer:GetMouse()
local active = false
local colorsss = {BrickColor.new("Lime green"), BrickColor.new("Hot pink"), BrickColor.new("Persimmon"), BrickColor.new("Toothpaste"), BrickColor.new("New yeller"), BrickColor.new("Cool yellow"), BrickColor.new("Really blue"), BrickColor.new("Really red"), BrickColor.new("Mauve"), BrickColor.new("Br. Br. yellowish green"), BrickColor.new("Br. Yellowish orange"), BrickColor.new("Royal purple"), BrickColor.new("Deep orange"), BrickColor.new("Teal"), BrickColor.new("Fog"), BrickColor.new("Cyan"), BrickColor.new("Lapis"), BrickColor.new("Artichoke")}

local rs = game:GetService('RunService')
local l = script.Parent

local rand = Random.new()
local range = NumberRange.new(65,80) --диапазон


local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local light = script.PointLight:Clone()
local playsoun = script.Soundf:Clone()
local playsoun2 = script.Soundf2:Clone()
light.Range = 0 
light.Parent = char:WaitForChild("Head")
playsoun.Parent = char:WaitForChild("Head")
playsoun2.Parent = char:WaitForChild("Head")


local player = game.Players.LocalPlayer
local playerChar = player.Character
local playerli2 = script.Parent.Parent.Character.Head:findFirstChild("PointLight")

function p()
	rs.RenderStepped:Connect(function()
		light.Range = rand:NextInteger(range.Min,range.Max)/10
	end)
end

function Light()
	local mouse = game.Players.LocalPlayer:GetMouse()
	local player = game.Players.LocalPlayer
	local playerChar = player.Character
	local playerli2 = script.Parent.Parent.Character.Head:findFirstChild("PointLight")
	if playerli2.Enabled == true then
		local soun2 = script.Parent.Parent.Character.Head:findFirstChild("Soundf2")
		soun2:Play()
		playerli2.Enabled = false
		task.wait(0.007)
		--local playerli1 = script.Parent.Parent.Character.Torso:findFirstChild("Soundf")
		--playerli1:Destroy()
		--playerli2:Destroy()
	else
		local soun = script.Parent.Parent.Character.Head:findFirstChild("Soundf")
		local l = script.Parent.Parent.Character.Head:findFirstChild("PointLight")
		local brikcol = colorsss[math.random(1, #colorsss)]
		soun:Play()
		l.Enabled = true
		l.Parent = script.Parent.Parent.Character.Head
		l.Range = 7 --- Change to any
		l.Brightness = 1 --- Change to any
		l.Shadows = true
		l.Color = Color3.new(brikcol.r, brikcol.g, brikcol.b)

		p()

	end
end



mouse.KeyDown:connect(function(key)
	if not active then
		active = true
		key = key:lower()
		if key == "f" then ---You can Change the key to use the Flashlight.
			Light()
		end
		task.wait(0.007)
	end
	active = false
end)

try

local light = script:WaitForChild("PointLight"):Clone()

maybe the light hasn’t loaded in yet and you need to wait for it

1 Like

i don’t understand how is that possible but it fixed everything, thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.