ModuleScript dont no what the mean "Rotate"

  1. What do you want to achieve? So i whant make Same Script but in ModuleScript

Screenshot_31

Exsampl from LOCAL_SCRIPT
6503620e-917a-4292-b1a1-e4c2dd40c57c

  1. What is the issue? SCRIPT (MODULE_SCRIPT)
local module = {}

module.Moser = function(Object: string, HowRotate: number)
	Object.Rotate = HowRotate
end

return module

(I just learn ModuleScript So i dont have any idea how he fuind “Rotate”)

LOCAL_SCRIPT

local UIgradient = script.Parent.UIStroke.UIGradient
local runService = game:GetService("RunService")


runService.RenderStepped:Connect(function()
	UIgradient.Rotation += 2 
end)

  1. What solutions have you tried so far? I just see In youtobe only in LocalScript but not in ModuleScript
    .

Object is a string. it has no properties. Did you mean to change the rotation of the Gradient? if so, you would need to define it and set the .Rotation in your code.

Edit: Don’t forget that modulescripts do not run on their own. They must be required by another script.

Like This?
module.Moser(Object.Rotate, 10)

No. Here is what it should look like:

local module = {} -- define module table

function module.rotate(gradient, newRot) -- create function
	gradient.Rotation = newRot
end
return module -- return module table

In the rotate function, you define the gradient and what you want to to rotate by. Here is example usage:

local module = require(whereveryourmoduleis) --modulescripts are usally held in replicatedstorage
local gradient = whereeveryourgradientis
local runservice = game:GetService("RunService")
runservice.Heartbeat:Connect(function()
 module.rotate(gradient, gradient.Rotation + 1)
end)
1 Like

In your case, you just want it to spin. you can replace the module.rotate with this code if you want:

function module.rotate(gradient)
 gradient.Rotation += 1
end)

Am have 1 quest

1- In RunServise you usse “Heartbeat” what it this

(Why you not use RanderStepped)

.Heartbeat is a runservice function that runs a function every frame. for example, if you connected a function like this:

local func = function()
 print("Hi")
end

And then connected it to heartbeat like so:

RunService.Heartbeat:Connect(func) -- or whatever you named the function

then your output will then print “Hi” every frame (basically a very fast loop with no yielding)

Edit: Renderstepped and heartbeat are pretty similar and are interchangable. Renderstepped runs before each frame, Heartbeat runs after each. This shouldn’t matter for small things such as spinning a gui’s color.

In this case, since you’re modifying a GUI element, I’d recommend using RenderStepped instead

Okei, but why RenderStepped if not HeartBeat?

As I said, they are pretty much the same if you don’t have a specific use for them. I just prefer Heartbeat because i find it easier to type.

1 Like

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