What is the issue? Issue is the error that comes up no matter what I can’t figure out how to fix it, the camera position won’t change because the error stops the event
The goal is a jumpscare
Client side
local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local CameraIn = game.ReplicatedStorage.Remotes.CameraIn
local PlayerCamera = game.ReplicatedStorage.Remotes.PlayerCamera
function shake() local camera = game.Workspace.Camera for i = 1,10 do wait()
camera.CoordinateFrame = camera.CoordinateFrame * CFrame.new(0,2,0) wait()
camera.CoordinateFrame = camera.CoordinateFrame * CFrame.new(0,-2,0) end end
CameraIn.OnClientEvent:Connect(function(Position,Focus,Time)
print(1)
local cam = game.Workspace.Camera
cam.CameraType = Enum.CameraType.Scriptable
cam:Interpolate(Position,Focus,Time)
print(4)
shake()
script.Sound:Play()
end)
PlayerCamera.OnClientEvent:Connect(function()
local camera = game.Workspace.Camera
script.Sound:Stop()
camera.CameraType = Enum.CameraType.Custom
end)
Server side
local played = false
local CameraIn = game.ReplicatedStorage.CameraIn
script.Parent.T.Touched:Connect(function(v)
if v.Parent:FindFirstChild("Humanoid") then
if played == false then
played = true
print(3)
CameraIn:FireClient(workspace.CameraPosition.CFrame, workspace.CameraAim.CFrame, 5)
print(1)
wait(1)
played = false
v.Parent.Humanoid.Health = 0
end
end
end)
Just to make sure you understand it’s an interpolation I’m trying to make with TweenService
CameraAim and CameraPosition are parts pointed to the scene I want to make
FireClient() requires a player object as first parameter but you are instead sending a CFrame. The player object must be the player who the server must fire the event to
Also Camera:Interpolate() is deprecated and you should use TweenService instead
FireAllClients() and FireClient() both fire an event but the difference is that, FireAllClients() will fire the event for all the player and therefore does not require a player object while FireClient() fires the event for a player only and so to identify the player it needs a player object
Ok, then I can use FireAllClients for tests and then figure out how to define player when I change it to fireclient instead of tweening and remaking it?
Since you are connecting the callback that fires the event to a .Touched event you can obtain the player object from the character using GetPlayerFromCharacter()
local played = false
local CameraIn = game.ReplicatedStorage.CameraIn
script.Parent.T.Touched:Connect(function(v)
if v.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(v)
if played == false then
played = true
print(3)
CameraIn:FireClient(plr["PlayerName"], workspace.CameraPosition.CFrame, workspace.CameraAim.CFrame, 5)
print(1)
wait(1)
played = false
v.Parent.Humanoid.Health = 0
end
end
end)
Mb & thanks, but the issue has moved to the client now as the camera won’t change its position to the requested parameters and not even fires as if I’d seen the print(1) at the beginning of the .OnClientEvent function
local player = game.Players.LocalPlayer
local CameraIn = game.ReplicatedStorage.Remotes.CameraIn
local PlayerCamera = game.ReplicatedStorage.Remotes.PlayerCamera
function shake() local camera = game.Workspace.CurrentCamera for i = 1,10 do wait()
camera.CoordinateFrame = camera.CoordinateFrame * CFrame.new(0,2,0) wait()
camera.CoordinateFrame = camera.CoordinateFrame * CFrame.new(0,-2,0) end end
CameraIn.OnClientEvent:Connect(function(plr,Position,Focus,Time)
print(1)
local cam = game.Workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
cam:Interpolate(Position,Focus,Time)
print(4)
shake()
script.Sound:Play()
end)
PlayerCamera.OnClientEvent:Connect(function()
local camera = game.Workspace.CurrentCamera
script.Sound:Stop()
camera.CameraType = Enum.CameraType.Custom
end)