Need help with my script that customized

my script is cloned but it dosnt want to rotate
pt = game.Lighting.Part:Clone()

pt.Parent = game.Workspace.CurrentCamera

local plr = game.Players.LocalPlayer

Mouse = plr:GetMouse()

local prev_mousehit

klik = false

Mouse.Button1Up:connect(function()

klik = false

end)

Mouse.Button1Down:connect(function()

klik = true

end)

local RunService = game:GetService(“RunService”)

RunService.RenderStepped:Connect(function()

if klik == true then

if Mouse.Hit.p == prev_mousehit then

pt.CFrame = CFrame.new(pt.Position, Vector3.new(Mouse.Hit.p.y,Mouse.Hit.p.z))

prev_mousehit = Mouse.Hit.p

end

end

end)

can anyone fix it for me?

1 Like

The problem is, LocalPlayer doesn’t work in ServerScripts (assuming that it is a serverscript). You need to get the player in an event, for example, using remote events.

okay so where do i need to replace or do?

Put the code in a local script in StarterPlayerStarterPlayerScripts

You can put your code inside triple backquotes to format it, like this
```
Code
```
That way we can see the script more clearly:

local pt = game.Lighting.Part:Clone()
pt.Parent = game.Workspace.CurrentCamera

local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
local prev_mousehit

klik = false

Mouse.Button1Up:connect(function()
	klik = false
end)

Mouse.Button1Down:connect(function()
	klik = true
end)

local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
	if klik == true then
		if Mouse.Hit.p == prev_mousehit then
			pt.CFrame = CFrame.new(pt.Position, Vector3.new(Mouse.Hit.p.y,Mouse.Hit.p.z))
			prev_mousehit = Mouse.Hit.p
		end
	end
end)

it dosnt work so heres a place so you can help me figure it out or add something
help.rbxl (151.7 KB)