Scripting school

Teach each other how to script, I only know basic stuff and fe2 scripts.

3 Likes

@Kriscross102RB

script.Parent is the instance script is inside of

:troll:

4 Likes

if game.workspace.part_ 1.Funny “dream” = 0 true

then game.workspace.part_ 1.Funny “Among” = 1 true

wait(numvalue) – self explanatory. Numvalue is here you put the number

game reference stuff in a game

A function yields until it is finished. wait() functions can delay.

function yieldScriptLOL(t)
  wait(t)
  print(tostring(t)) -- Converts a number to a string
  return true
end

spawn() and delay()

spawn() creates sort of its own script inside the script. Any variable or function still work as if its a part of the actual script (lmao i am so bad at leeching T-shirt-ching teaching). Any yields are only inside it. Errors ain’t gonna have crap with it.

spawn(function()
  yieldScriptLOL("TheStringBehindTheError")
end)

delay() does a similar thing, but it doesn’t yield unlike wait().

delay(4.2, function()
  print("Line 2: Hello, delay()!")
  warn("Line 3: Who is delay()?")
  error("ha nubs i will kill this function, it will never end!")
  -- Once an error rolls out, this function crashes.
  -- If the error isn't inside any function, the script crashes.
  game.Workspace.FallenPartsDestroyHeight = -500 + (math.pi() / 10)
  -- The line above won't run because of that stupid error! Grr!
end)
1 Like

if game.Workspace.part_1.Funny.Dream.Value = 0
then game.Workspace.part_1.Funny.Among.Value = 1

corrected Unless it wrong which it probably is :troll:

make variables all lowercase and explorer objects start with an uppercase
makes it easy to remember which is a variable and which is an object

A script that I learned via the discord:

  Local Lib = workspace.Multiplayer.GetMapVals:Invoke() --Has: Map, Script, Button, btnFuncs
  Lib.Button:connect(function(p, bNo) if Lib.btnFuncs[bNo] then Lib.btnFuncs [bNo] (bNo, p) end end)

    local Tween = game:GetService('TweenService') 

    wait(10)
    Tween:Create(Lib.Map.Intro._MovingDoor1,
    TweenInfo.new(2, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out),
    {CFrame = Lib.Map.Intro._MovingDoor1.CFrame + Vector3.new(0, 5, 0)}):Play() 

it makes the moving platforms have different animations, just like construction Thrill

TweenInfo.new(x, time that takes to complete the action, just like normal scripts

Enum.EasingStyle.TYPEHERE, write the type of animation that u want the platform to do, for example, Bounce, Elastic, Cubic, etc.
https://developer.roblox.com/en-us/api-reference/enum/EasingStyle

local Tween = game:GetService('TweenService')

If you want the platforms of your map having different animations, you must insert this only once after these lines

  Local Lib = workspace.Multiplayer.GetMapVals:Invoke() --Has: Map, Script, Button, btnFuncs
  Lib.Button:connect(function(p, bNo) if Lib.btnFuncs[bNo] then Lib.btnFuncs [bNo] (bNo, p) end end)
2 Likes

Ik this is an older post but does using a model break it? I cant seem to get the model to move even after referencing it, the part references lib.map.intro.MovingDoor1, which is a model but it wont move.

here is the script:

Lib.btnFuncs[3] = function()

local Tween = game:GetService('TweenService') 

wait(3)
Tween:Create(Lib.Map.Intro._MovingDoor1,
	TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut),
	{CFrame = Lib.Map.Intro._MovingDoor1.CFrame + Vector3.new(0, 5, 0)}):Play()

end

anyone?

ok so how am I supposed to tween/move a model

idk if moving script works with model

Works, but you need use a script to get all parts inside of the model.

I learning Scripting and this help me Thank yuo

1 Like

Spawn and delay create new threads inside the script to prevent yielding, spawn will run after a minimum timer of 29 milliseconds, while delay will run after x seconds have passed, which are put as parameters in the code: delay(x, ...). You can get around the delay that spawn uses to start with by using coroutines. the only downside is that it is way harder to handle errors with them rather than spawn (I might say (it’s a pain in the A#$)). Finally, it’s worth noting that all of the functions, spawn, delay, and coroutine, are all asynchronous, meaning they all run at the same time.

Wow, that’s probably the most nerdy response I could of said

4 Likes

So coroutines are better?

If you want it to run faster by 0.029 seconds then yes

1 Like

Also, I create a new form to make Custom Text Script now.