What are some scripts that take long?

I’m currently working on my module script used to simplify code.

Module here: SimpleZ's Simple Commands - Roblox
I need help thinking of scripts that might be complicated that could be simplified as a function.

The script already contains:

Functions

Interpolate (Tween Service)
Ray-cast (Visualized or Hidden)
Animate
Kick
Move
Rotate
Forward Move
Point Towards
Teleport Place (Takes a player)
Teleport Block (Takes a player character)
Prompt User (Only supports up to 4 types :/)

What are some scripts that should be simplified?

An example of a function (Interpolate):
Sorry if code is pasted weirdly. Copy and paste problems! :confused:

1. function SimpleZ.Interpolate(Obj, Time, Goals, EasingStyle, Direction, RepeatAmount, reverse, delaytime)
2. 	
3. 		local Success, Error = pcall(function()

4. 			TweenService:Create(Obj,TweenInfo.new(Time, EasingStyle, Direction, RepeatAmount, reverse, delaytime),Goals):Play()

5. 		end)

6. 		if Success then

7. 			print(script.Name .. " - Interpolated " .. tostring(Obj) .. " in " .. tostring(Time) .. " seconds with goals: " .. tostring(Goals))

8. 		else

9. 			print(script.Name .. " - Couldn't Interpolate " .. tostring(Obj) .. " in " .. tostring(Time) .. " seconds! ERROR!")
10. 			warn(Error)

11. 		end
12. 		
13. 	end

I don’t know if this is where the topic belongs. I’ll just wait and see if this gets taken down. :confused:

2 Likes

Your in the right topic. Run the code a few times with part that seem unnecessary. That might be able to make the script smaller and more understandable.

2 Likes

There’s no need for this, just making a tween will not cause any error unless you do it wrong, you don’t need a function to tween objects with tweenservice

it’s like doing a function/module to print

Also you could reduce it to this

local suc,tween = pcall(game:GetService('TweenService').Create,game:GetService('TweenService'),workspace.Part,TweenInfo.new(1),{Position = workspace.Part.Position + Vector3.new(0,6,0)}) if (suc) then tween:Play() end
1 Like

Probably should’ve been more specific. I wanted to know some scripts that can be simplified. Not the code inside the module itself. For example:

1.  function SimpleZ.RayCast(Origin, Direction, Visualized, Radius)
2. 	
3. 		local Success, Error = pcall(function()

4. 			if Visualized == true then

5. 				local ray = Ray.new(Origin, Direction)
6. 				local Hit, Position = workspace:FindPartOnRay(ray)
7. 				local Distance = (Origin - Position).Magnitude

8. 				local Part = Instance.new("Part")

9. 				Part.Name = "Visualized Ray"
10. 				Part.Anchored = true
11. 				Part.CanCollide = false
12. 				Part.Parent = game.Workspace

13. 				Part.Material = "Neon"
14. 				Part.BrickColor = BrickColor.new("Really red")

15. 				Part.Size = Vector3.new(Radius, Radius, Distance)
16. 				Part.CFrame = CFrame.lookAt(Position, Origin) * CFrame.new(0, 0, -Distance/2)

17. 				local HitPart = Hit
18. 				local Pos = Position

19. 				return HitPart, Pos, Part

20. 			else

21. 				local ray = Ray.new(Origin, Direction)
22. 				local Hit, Position = workspace:FindPartOnRay(ray)

23. 				local HitPart = Hit
24. 				local Pos = Position

25. 				return HitPart, Pos

26. 			end

27. 		end)

Basically you would write this code into a script which would take a while to write all from scratch.

findpartonray is deprecated tbh

1 Like

Yeah I know. I figured that out 2 days ago. I’m actually currently working on that to be honest…