Why isn't my module script working well [Half-Solved]

I’m trying to make script that activates module script function but, it dont make sense, my module script is creating 2 parts instead of just one

The script

local Model = CreateCloudModule.CreateStand(game.Workspace:WaitForChild("CloudModel"):WaitForChild("CloudMunicipe"), 1)
game.Debris:AddItem(Model,3)

Module script

local module = {}
local TweenService = game:GetService("TweenService")

module.CreateStand = function(StartPosition, NumberOfPoints)
	local Model = Instance.new("Model",game.Workspace.DebrisFolder)
	for i = 0,NumberOfPoints do
		local OffSet = Vector3.new(math.random(-45, 45),math.random(-45, 45),math.random(-45, 45))
		
		if i == 1 or i == NumberOfPoints then
			OffSet = Vector3.new(0,0,0)
		end
		
		local Part = game:GetService("ReplicatedStorage").FruitEvent.FruitModelClone.StormStormNoMi.Clouds.Cloud:Clone()
		Part.Parent = Model
		
		Part.Position = StartPosition.Position + (StartPosition).Position * i * (StartPosition).Position/NumberOfPoints + OffSet
		
		task.wait(0.1)
		
		local goal = {}
		goal.Position = StartPosition.Position

		local tweenInfo = TweenInfo.new(2.5)

		local tween = TweenService:Create(Part, tweenInfo, goal)

		tween:Play()
	end
	
	return Model
end

return module

The module is inside of script, how i fix that.

1 Like

Replace the line down here

with function module.CreateStand(StartPosition, NumberOfPoints). That should fix the issue.

1 Like

it dont work ;(
image

Seems to work fine for me. No errors.

sooo my module is inside of my script is it a problem?

both work the exact same, there is basically no difference besides how they are set up:

func1 = function(arg)
    print(arg)
end

function func2(arg)
    print(arg)
end

func1("Hi, I still work!") -- "Hi, I still work!"
func2("Hello") -- "Hello"

The Second example however is more “proper” version of this.

1 Like

soo why is taking error, its make 2 parts in one model ;(

do you mean like the module is parented to the script or you wrote the module code inside of the script.

yes is that but i think dong have any problem

Can you send the line where it errors?

To fix the problem, you should change the line:

for i = 0,NumberOfPoints do

to:

for i = 1,NumberOfPoints do

This is because in the original line, the “for” loop is being executed one more time than expected because it starts at 0 instead of 1.

2 Likes

hey guy’s sorry for not saying nothing, i was sleeping but now is just creating one part but, the OffSet is not working ;(

so, it is not having any error in OutPut just the position that is having error

But now it just creates a part that spawns on top of the main (Point) part, Part where the created part of the script module has to move up to, and it works but the OffSet is not having effect

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.