Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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

Log in to vote
1
Answered by
Etheroit 178
7 years ago

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)
0
thank you, before i tried scripting it locally, but thanks. now i know i need to use currentCamera trubudist 40 — 7y
0
:) No problem Etheroit 178 — 7y
Ad

Answer this question