I’m trying to organize my code so that it’s not confusing in the future, but everything is broken now and whenever I try to access a value in the Variables module nothing happens(printing doesn’t work).
Note: I’m supposed to be able to pick up bananas and eat them and there is supposed to be an animated ViewModel on screen.
Main Client
local Variables = require(script.Variables)
Variables.Bindables.OnClient.Event:Connect(function(signal,par1,par2)
if signal == "EnableViewModel" then
print("Success")
Variables.RenderSteps:EnableViewModel(Variables.Controller)
Variables.RenderSteps:AnimateViewModel(Variables.Controller)
elseif signal == "EatBanana" then
local length = Variables.Controller:RewardBanana()
Variables.Rig:Destroy()
Variables.Bindables.OnClient:Fire("ClearInventory")
Variables.SoundPlayer:PlaySound("EatBananaSound",Variables.Root)
end
end)
Variables.Bindables.ToClient.OnClientEvent:Connect(function(signal,par1,par2)
if signal == "RigBanana" then
Variables.Rig.new(Variables.Player,par1):Init()
end
end)
Variables Module
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Client = script.Parent
local Variables = {}
Variables.Player = game:GetService("Players").LocalPlayer
Variables.Character = Variables.Player.Character or Variables.Player.CharacterAdded:Wait()
Variables.Root = Variables.Character.HumanoidRootPart
Variables.Humanoid = Variables.Character.Humanoid
Variables.SoundPlayer = require(Client.SoundPlayer)
Variables.Contexts = require(Client.Contexts)
Variables.Collections = require(Client.Collections)
Variables.RenderSteps = require(Client.RenderSteps)
Variables.Rig = require(Client.Rig)
Variables.Controller = require(Client.Controller).new()
Variables.Remotes = ReplicatedStorage.Remotes
Variables.Animations = ReplicatedStorage.Animations
Variables.Bindables = ReplicatedStorage.Bindables
return Variables