I’m trying to make a shop system where monkeys dive into this hole in the center of the map and
The problem is, I’m having this weird glitch where my ViewModel is stuck in a certain position and my character is acting strangely.
Streamable of example:
External MediaCode samples
Server:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage.Remotes
local ShopPosition = workspace.ShopPosition
local HumanoidTable = {}
local Interact = {}
Interact.__index = Interact
function Interact.new(Player)
local self = setmetatable({},Interact)
self.Player = Player
self.Character = self.Player.Character or self.Player.CharacterAdded:Wait()
self.Humanoid = self.Character.Humanoid
self.Root = self.Character.HumanoidRootPart
return self
end
function Interact:Init()
self:UnenableControls()
Remotes.ToClient:FireClient(self.Player,"ShopCamera")
end
function Interact:UnenableControls()
self.Root.Position = ShopPosition.Position
self.Humanoid.WalkSpeed = 0
self.Humanoid.JumpPower = 0
self.Humanoid.AutoRotate = false
HumanoidTable[self.Player] = self.Humanoid
end
function Interact:Reverse(player)
local humanoid = HumanoidTable[player]
if humanoid then
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
humanoid.AutoRotate = true
end
humanoid = nil
end
return Interact
Client:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local Remotes = ReplicatedStorage.Remotes
local Camera = workspace.CurrentCamera
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Root = Character.HumanoidRootPart
local Humanoid = Character.Humanoid
local ShopGoal = workspace:WaitForChild("ShopGoal")
local ShopPosition = workspace:WaitForChild("ShopPosition")
local ShopCutscene = {}
function ShopCutscene:Init()
Remotes.ToClient.OnClientEvent:Connect(function(signal)
if signal == "ShopCamera" then
local newC = script.CameraModel:Clone()
newC.Parent = workspace
newC:PivotTo(Root.CFrame)
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = newC.Cam1.CFrame
self:TweenRoot()
self:TweenCamera(newC)
end
end)
end
function ShopCutscene:TweenCamera(newC)
local info = TweenInfo.new(0.75,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
for i = 2,3 do
local tween = TweenService:Create(Camera,info,{CFrame = newC:FindFirstChild("Cam"..tostring(i)).CFrame})
tween:Play()
tween.Completed:Wait()
end
Camera.CameraSubject = Humanoid
Camera.CameraType = Enum.CameraType.Custom
newC:Destroy()
end
function ShopCutscene:TweenRoot()
local info = TweenInfo.new(1.25,Enum.EasingStyle.Back,Enum.EasingDirection.Out)
local tween = TweenService:Create(Root,info,{Position = ShopGoal.Position})
tween:Play()
end
return ShopCutscene