You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I’m using a BindableEvent to send two arguments from one LocalScript (located in a ScreenGUI) to another LocalScript (in PlayerScripts). This will cause the camera to move smoothly over to a new subject. -
What is the issue? Include screenshots/videos if possible!
The issue is that there are no errors, and I can’t find the problem. I’ve placed a “print” in the connection but found no output. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have double-checked the hierarchy and tried different variables. I’m not really sure what else to try. Some similar posts have been fixed with the solution regarding the fact that the BE was fired before a connection could be made, but I doubt that is the case, as the first time it’s fired, it’s well into the game.
-- Script A
local function changeCamSubject(subject, newFOV) game:GetService("ReplicatedStorage").Tutorial.ChangeSubject:Fire(subject, newFOV) end
-- There's a bunch of code between these lines, but it all runs fine!
changeCamSubject(workspace.KingNoob, 3)
-- There's also a bunch of code after this that runs fine as well.
-- Script B
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local tutFile = game:GetService("ReplicatedStorage").Tutorial
plr.CharacterAdded:Wait()
local char = plr.Character
local cam = workspace.CurrentCamera
local zoom = 100
cam.FieldOfView = 10
cam.CameraType = Enum.CameraType.Scriptable
local newSubject = false
while true do
if newSubject == true then
break
end
newSubject = false
game["Run Service"].RenderStepped:wait()
if char then
if char:FindFirstChild("Head") then
cam.CFrame = CFrame.new(Vector3.new(char.Head.Position.X+zoom,char.Head.Position.Y+zoom,char.Head.Position.Z+zoom),char.Head.Position)
end
end
end
-- Switching subjects tween & follow
tutFile.ChangeSubject.Event:Connect(function(subject, newFOV)
print("Switching subjects") -- Not printing; nothing after this runs (seemingly)
newSubject = true
game["Run Service"].RenderStepped:wait()
if subject:FindFirstChild("Head") then
local tweenService = game:GetService("TweenService")
local goal = {}
goal.CFrame = CFrame.new(Vector3.new(subject.Head.Position.X+zoom,subject.Head.Position.Y+zoom,subject.Head.Position.Z+zoom),subject.Head.Position)
goal.FieldOfView = newFOV
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingStyle.InOut)
local tween = tweenService:Create(cam, tweenInfo, goal)
tween:Play()
wait(1)
newSubject = false
while true do
if newSubject == true then
break
end
newSubject = false
game["Run Service"].RenderStepped:wait()
cam.CFrame = CFrame.new(Vector3.new(subject.Head.Position.X+zoom,subject.Head.Position.Y+zoom,subject.Head.Position.Z+zoom),subject.Head.Position)
end
end
end)