For some reason this script does not really work? could it be the type of script i'm using? Im not too sure.
This is the script.
local UIS = game:GetService("UserInputService") local MainBlock = game.Workspace.MainBlock UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.W then MainBlock.Position = Vector3.new(MainBlock.Position.X + 2,MainBlock.Position.Y,MainBlock.Position.Z) end end)
I am using a regular script, not local if that helps.
What your trying to achieve is not gonna work.(Unless it's filteringenabled = false) What you need to do is use a localscript to get input and change the position server side
--localscript local UIS = game:GetService("UserInputService") local MainBlock = game.Workspace.MainBlock local remote = game.ReplicatedStorage.Mainblock -- whatever it's called UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.W then remote:FireServer(CFrame.new(MainBlock.Position.X+2,MainBlock.Position.Y,MainBlock.Position.Z)) end end) --serverscript local remote = game.ReplicatedStorage.Mainblock local MainBlock = game.Workspace.MainBlock remote.OnServerEvent:Connect(function(plr, pos) MainBlock.Position = pos end)
Make sure there's a remote called Mainblock or whatever. If your wondering why I used a remote event it's because if u change the position locally only the player will see it and not the other players.
--click detector --put script inside the clickdetector --put clickdetector inside MainBlock --must be a regular script local click = script.Parent local MainBlock = click.Parent click.MouseClick:Connect(function(plr) MainBlock.CFrame = CFrame.new(MainBlock.Position.X+2,MainBlock.Position.Y,MainBlock.Position.Z) end)
Don't use a regular script if you're trying to get input from the player. Put it in a local script.
I think you can make a button (you can do that by simply add ClickDetector into some kind of part, etc...)
In that button, insert a script (server type) and put this:
local clickDetector = script.Parent.ClickDetector clickDetector.MouseClick:Connect(function() MainBlock.Position=Vector3.new(MainBlock.Position.X+2, MainBlock.Position.Y, MainBlock.Position.Z) end)
EDIT: Well, here the change: So if you want the camera focus to the part, you have to put some RemoteEvent:
*ServerScript
local clickDetector = script.Parent.ClickDetector local reEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent") local mainPosition = MainBlock.Position clickDetector.MouseClick:Connect(function() MainBlock.Position=Vector3.new(MainBlock.Position.X+2, MainBlock.Position.Y, MainBlock.Position.Z) reEvent:FireCilent(plr, mainPosition) end)
*LocalScript:
local camera = workspace.CurrentCamera local reEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent") reEvent.OnCilentEvent:Connect(function(position) camera.CFrame = CFrame.new(camera.Position, position) end)
Hope this help you.
You'll have to put it in a local script as if you want to get input from a specific player you'll need a Local Script, except for that everything looks good!