Nyxifier
(nyxon)
March 16, 2023, 6:47pm
1
Hey!
I’m trying to tween player’s camera on part (clickDetector) MouseClick. However, it doesn’t work at all.
I tried using both LocalScript and ServerScript, but that didn’t help me, and I don’t even get an error, which is the most annoying part.
This is the code:
local clickDetector = script.Parent
local TweenService = game:GetService("TweenService")
local camera = game.Workspace.CurrentCamera
clickDetector.MouseClick:Connect(function()
local TweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false
)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = game.Workspace.Computer.Monitor.monitor.TweenFirstPosition.CFrame
local tween = TweenService:Create(camera, TweenInfo, {CFrame = game.Workspace.Computer.Monitor.monitor.CameraPosition.CFrame})
tween:Play()
end)
1 Like
hasoco
(kan ye)
March 16, 2023, 6:51pm
2
Is this a local script or a server script??
Nyxifier
(nyxon)
March 16, 2023, 6:53pm
3
It’s currently a ServerScript.
hasoco
(kan ye)
March 16, 2023, 6:53pm
4
local TweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false
)
It might have to do with the 0 part, because that’s how many times the tween is being repeated, so if the tween is being repeated 0 times, it wont play.
Not true, that’s the amount of times that it repeats after tweeting once.
1 Like
Nyxifier
(nyxon)
March 16, 2023, 6:55pm
6
That didn’t help me either, even if it’s on ServerScript.
hasoco
(kan ye)
March 16, 2023, 6:56pm
7
That’s because CurrentCamera is only for local scripts, while workspace.Camera is for server scripts.
1 Like
Could you try to print when the MouseClick fires to see if it even triggers?
I suggest using FireClient for the ServerScript.
Nyxifier
(nyxon)
March 16, 2023, 7:02pm
10
I’m now getting an error “Argument 1 missing or nil”.
This is the ServerScript code:
local clickDetector = script.Parent
local event = game.ReplicatedStorage.ComputerCamera
clickDetector.MouseClick:Connect(function()
event:FireClient()
end)
This is the LocalScript code:
local TweenService = game:GetService("TweenService")
local camera = game.Workspace.CurrentCamera
local event = game.ReplicatedStorage.ComputerCamera
event.OnClientEvent:Connect(function()
local TweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false
)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = game.Workspace.Computer.Monitor.monitor.TweenFirstPosition.CFrame
local tween = TweenService:Create(camera, TweenInfo, {CFrame = game.Workspace.Computer.Monitor.monitor.CameraPosition.CFrame})
tween:Play()
end)
1 Like
You need to put the player inside of FireClient()
like this FireClient(player) (MAKE SURE ITS NOT CHARACTER)
1 Like
Nyxifier
(nyxon)
March 16, 2023, 7:04pm
12
Thanks, tweening is now working perfectly.
2 Likes
system
(system)
Closed
March 30, 2023, 7:04pm
13
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.