Script not working on client (still need help)

This script is not working on the client…
it runs fine as a script but not as a localscript.

local p1 = script.Parent local p2 = p1
local function Raycast()
	local hit
	local position
	local normal
	local ray = Ray.new(p1.Position, Vector3.new(0,-1,0)*100)
	hit,position,normal = workspace:FindPartOnRayWithIgnoreList(ray, {p2})
	return({position,normal})
end

while wait() do
	local info = Raycast()
	p2.CFrame = CFrame.new(info[1],info[1]-info[2])*CFrame.Angles(math.rad(90),0,0)
end
1 Like

Could it be outputting any errors?

edit: If you expect the stuff happening on the client to replicate to the server, it doesn’t do that. Local scripts only show up on the client, they don’t do anything anywhere else.

the top part there. probaly this is the error

Error:

local p1 = script.Parent local p2 = p1

Probaly the fix:

local p1 = script.Parent

try using this instead of local p2 = p1

Make sure that the localscript is inside of the player and not anywhere else.

i was going to replicate it using a remote event

local p1 = script.Parent
local function Raycast()
	local hit
	local position
	local normal
	local ray = Ray.new(p1.Position, Vector3.new(0,-1,0)*100)
	hit,position,normal = workspace:FindPartOnRayWithIgnoreList(ray, {p1})
	return({position,normal})
end

while task.wait() do
	local info = Raycast()
	p1.CFrame = CFrame.new(info[1],info[1]-info[2])*CFrame.Angles(math.rad(90),0,0)
end

All of these still do not work! i have no idea why…
all that this script does is it sends a ray down till it hits a surface and then positions the part at that surface…

it works perfectly fine when its in a script but not in a localscript! i need this on the localscript because a skinned mesh is animated on client side for framerate

and there are no error’s whatsoever. this is really strange and i have never had anything like this happen to me on roblox (except sleeping parts)

Here is the place that this is not working on.
PostitioningNotWorking.rbxl (33.8 KB)

I fixed this by fixing the rest of my game but this doesnt work with skinned meshes soooooooooooooooo

#wasteof5hours