Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesnt the camera focus and dummy rotate on button click (Remote Event)?

The game is on FE btw

Local script



local player = game.Players.LocalPlayer
local char = player.Character


if not char or not char.Parent then
    char = player.CharacterAdded:wait()
end

local cam = game.Workspace.Camera



local newGameButton = script.Parent.Parent:WaitForChild('StartScreen'):WaitForChild'Frame':WaitForChild'NewGameButton'
local newGameButtonWhite = script.Parent.Parent:WaitForChild('StartScreen'):WaitForChild'Frame':WaitForChild'NewGameBorderWhite'
local characterScreen =  script.Parent.Parent:WaitForChild('CaCScreen'):WaitForChild'Frame'

local rotateDummyRemote = game:GetService('ReplicatedStorage'):WaitForChild('Remotes'):WaitForChild'RotateDummyRemote'

local dummy = workspace:WaitForChild(player.Name..'-'..'Dummy')
local torso = dummy:WaitForChild'Torso'


local function RotateCamera()
	
end



newGameButton.MouseButton1Down:connect(function()
	cam.CameraSubject = torso
	cam.CameraType = "Follow"

	
	
	rotateDummyRemote:FireServer({dummy })
end)

Server Script

local replicatedStorage = game:GetService('ReplicatedStorage')


local rotateDummyRemote = Instance.new('RemoteEvent')
rotateDummyRemote.Parent = replicatedStorage:WaitForChild'Remotes'
rotateDummyRemote.Name = 'RotateDummyRemote'
	


rotateDummyRemote.OnServerEvent:connect(function(player, arguments)

	
	

	
arguments[1]:WaitForChild'Torso'.CFrame = arguments[1]:WaitForChild'Torso'.CFrame * CFrame.new(0,.01,0) * CFrame.Angles(0,.6,0)

	
	
end)

It works only in studio but not in game, and no errors show up on output

1 answer

✓ Accepted answer
  1. Im not sure can client sided scripts access workspace. I think no.
  2. Try replacing game.Workspace.Camera with game.Workspace.CurrentCamera
  3. I prefer placing dummy on client side (no server script is needed)

SOLUTION You can remove server script and place this in client sided script. NOTE: PLACE DUMMY MODEL IN REPLICATED STORAGE AND NAME IT "Dummy"

local player = game.Players.LocalPlayer
local char = player.Character


if not char or not char.Parent then
    char = player.CharacterAdded:wait()
end

local cam = game.Workspace.CurrentCamera

local dummy = game.ReplicatedStorage.Dummy:Clone()
dummy.Parent = cam
local torso = dummy:WaitForChild("Torso")

local newGameButton = script.Parent.Parent:WaitForChild('StartScreen'):WaitForChild'Frame':WaitForChild'NewGameButton'
local newGameButtonWhite = script.Parent.Parent:WaitForChild('StartScreen'):WaitForChild'Frame':WaitForChild'NewGameBorderWhite'
local characterScreen =  script.Parent.Parent:WaitForChild('CaCScreen'):WaitForChild'Frame'



newGameButton.MouseButton1Down:connect(function()
    cam.CameraSubject = torso
    cam.CameraType = "Follow"
    torso.CFrame = torso.CFrame * CFrame.new(0,.01,0) * CFrame.Angles(0,.6,0)
end)

2 comments

0

thank you, before i tried scripting it locally, but thanks. now i know i need to use currentCamera

0

:) No problem

This discussion is preserved as it was. New answers, comments, and votes are closed.