Script works on one place but not the other

this first person script :

local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")

char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)

for i, v in pairs(char:GetChildren()) do
	if v:IsA("BasePart") and v.Name ~= "Head" then

		v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
			v.LocalTransparencyModifier = v.Transparency
		end)

		v.LocalTransparencyModifier = v.Transparency

	end
end

RunService.RenderStepped:Connect(function(step)
	local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)
	local ignoreList = char:GetChildren()

	local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)

	if hit then
		char.Humanoid.CameraOffset = Vector3.new(0, 0, -(char.Head.Position - pos).magnitude)
		print("a")
	else
		char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)
	end
end)
print("a12")

this works on an older place but doesnt work on a newer place. i created a new place, pasted the script onto playercharacterscript using local script but it doesnt work!!! can someone please help me i am so confused…

1 Like

try putting it inside “StarterGui”

Humanoid is not a valid member of Model “Workspace.cheshnut”

if i put it in the usual startercharscript it would be

Head is not a valid member of Model “Workspace.cheshnut”

I am using R6, this script works on my other game but not this.
image

nevermind, i added wait for child for head and it worked. it might be due to the fact that the older place had more script to process that i dont need waitforchild for certain tests.

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