I’m trying to make a make a portal gun, but whenever I test it out, my camera zooms in and I can’t zoom out or move.
Here’s my Tweening script on the client-side:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Camera = workspace.CurrentCamera
local Blue = Color3.fromRGB(0, 85, 122)
local Orange = Color3.fromRGB(255, 120, 0)
local Part
local IdentifierToSend
local function tweenCamera(Time, Style, Direction, FOV)
local info = TweenInfo.new(Time, Enum.EasingStyle[Style], Enum.EasingDirection[Direction], 0, false, 0)
local Tween = TweenService:Create(
Camera,
info,
{FieldOfView = FOV}
)
Tween:Play()
Tween.Completed:Wait()
end
local function tweenUI(Time, Style, Direction, Goal)
local info = TweenInfo.new(Time, Enum.EasingStyle[Style], Enum.EasingDirection[Direction], 0, false, 0)
local info2 = TweenInfo.new(.2, Enum.EasingStyle[Style], Enum.EasingDirection[Direction], 0, false, 0)
coroutine.wrap(function()
local Tween1 = TweenService:Create(
script.Parent.Frame,
info,
{BackgroundTransparency = Goal[2]}
)
Tween1:Play()
Tween1.Completed:Wait()
local Tween2 = TweenService:Create(
script.Parent.Frame,
info,
{BackgroundColor3 = Goal[1], BorderColor3 = Goal[1]}
)
Tween2:Play()
Tween2.Completed:Wait()
ReplicatedStorage.PortalEvent:FireServer("Teleport", Part, IdentifierToSend)
local Tween3 = TweenService:Create(
script.Parent.Frame,
info,
{BackgroundTransparency = Goal[2] + 1}
)
Tween3:Play()
tweenCamera(.5, "Sine", "InOut", 70)
end)()
end
ReplicatedStorage.PortalEvent.OnClientEvent:Connect(function(Argument, PartName, Identifier)
if not Argument or not PartName then return end
if Argument == "manipulateCamera" then
if PartName == "BluePortal"..Identifier then
Part = "OrangePortal"..Identifier
IdentifierToSend = Identifier
script.Parent.Frame.BackgroundColor3 = Blue
script.Parent.Frame.BorderColor3 = Blue
tweenUI(1, "Sine", "InOut", {Orange, 0})
elseif PartName == "OrangePortal"..Identifier then
Part = "BluePortal"..Identifier
IdentifierToSend = Identifier
script.Parent.Frame.BackgroundColor3 = Orange
script.Parent.Frame.BorderColor3 = Orange
tweenUI(1, "Sine", "InOut", {Blue, 0})
end
tweenCamera(.5, "Sine", "InOut", 120)
tweenCamera(.5, "Sine", "InOut", 0)
end
end)
I also have a module for the player that might be part of where the error is coming from:
local module = {}
function module:Freeze(Player)
Player.Character.Humanoid.WalkSpeed = 0
Player.Character.Humanoid.UseJumpPower = true
Player.Character.Humanoid.JumpPower = 0
end
function Unfreeze(Player)
Player.Character.Humanoid.WalkSpeed = 16
Player.Character.Humanoid.UseJumpPower = true
Player.Character.Humanoid.JumpPower = 50
end
return module
If you think you know what I did wrong, pls let me know. Thank you in advance for your help.