Im trying to make custom camera movement for a game and my camera part won’t move it won’t even print start
RunService = game:GetService("RunService")
player = game:GetService("Players").LocalPlayer
camerapart = script.Parent
print("start")
RunService.RenderStepped:Connect(function()
camerapart.Position.X = Vector3.new(player.Character.Head.X)
camerapart.Position.Z = Vector3.new(player.Character.Head.Z)
print("loop")
end)
1 Like
You need to do it like this.
local RunService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer --or game.Players.LocalPlayer
local camerapart = script.Parent
local character = player.Character or player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")
print("Started!")
RunService.Stepped:Connect(function()
camerapart.Position.X = Vector3.new(head.X)
camerapart.Position.Y = Vector3.new(head.Y)
camerapart.Position.Z = Vector3.new(head.Z)
print("Camera changed")
end)
Where is the script parented to? is the camera part locally created
Script is parented to camera part and camera part is a sphere in workspace
You can’t call game.Players.LocalPlayer on a Script.
oops I meant its a local script sorry bout that
Local Script inside of a part?
Yep btw this is what I want
I want the camera part to move with the player
Ignore the random people my friend wanted me to add people
So you want the part to move with the player? And the camera to be the part?
1 Like
Yeah that’s what I want so its kinda like follows the player
First of all, you can’t have a LocalScript inside a part. Those only run on the client-side.
No not really (character limit)
Put the local script in StarterCharacterScripts
RunService = game:GetService("RunService")
player = game:GetService("Players").LocalPlayer
camerapart = game.Workspace["Sphere_or_whatever_you_named_it"]:Clone()
camerapart.Parent = game.Workspace
print("start")
RunService.RenderStepped:Connect(function()
camerapart.Position.X = Vector3.new(player.Character.Head.X)
camerapart.Position.Z = Vector3.new(player.Character.Head.Z)
print("loop")
end)
1 Like
Is it a LocalScript? If yes, copy everything you have inside it and delete it from the part.
1 Like
You misspelled camerapart. (Character limit)
Does the script work? @R41NB0W4C3
He can’t have errors because it won’t run on a local script inside of a part.
Im testing it rn (character limit)
Edit: Error says “X cannot be assigned to”
Ok. Let me know if it works. If it doesn’t, I have a script I think should work.
Ok, question. Do you want the camera to be the exact position of the camera part?