Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What can I save using module scripts?

I'm trying to use a module script to create an orb object for each player and call the same methods on each individual orb object. Here's what I tried doing for the constructor of the module script.

function Orb.New(Player)
	local self = setmetatable({}, Orb)
	local OrbObject = Instance.new("Part")
	OrbObject.Shape = ("Ball")
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
	OrbObject.CFrame = HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
	OrbObject.Parent = Character
	self.OrbObject = OrbObject
	self.Player = Player
	self.X = 20	
	return self
end

In other methods, trying to reference self.X works perfectly fine, but whenever I try to access self.OrbObject, it gives me nil. What's the problem, and what should I do? Or is there a possible issue somewhere outside of the constructor?

1 comment

0

Maybe you can post the whole module, because I'm pretty sure the problem is not in the New() method.

1 answer

I don't really know what's the problem but maybe this is the problem:

You didn't locate the Instance.new("Ball") to anywhere, so it stills has the value on (cuz the table saved) but it can't find where is it.

Probably this is the problem, if it doesn't work tho I also don't know :>

Am I only thought Geometry Dash's orbs while seeing this script?

If it works don't forget to mark this as the answer :P

This discussion is preserved as it was. New answers, comments, and votes are closed.