Questions tagged [luau]

Luau is a scripting language based on Lua 5.1.

The luau language was developed by Roblox. The language's website is at https://luau-lang.org/.

123 questions
3
votes
1 answer

Typechecking not working for generic string keys in Luau?

I'm trying to create a dictionary data structure that contains several CustomType objects that can be associated with any string key. I figured I could just use {[string]: CustomType} as my dictionary type, like this: --!strict type CustomType = { …
3
votes
3 answers

Roblox Why can't I get Players.LocalPlayer.Character in game

I have been following many tutorials that use: game.Players.LocalPlayer.Character However every time I try to run this I get an error saying: Players.icrann.PlayerScripts.Script:2: attempt to index field 'Character' (a nil value) I am trying to…
Crann Moroney
  • 356
  • 2
  • 4
  • 13
2
votes
1 answer

How to save a BoolValue in a DataStore System

I'm trying to make a system that saves a value so that if the player has that value then he gains the powers of that particular item but I'm not able to make that happen. There are no errors in the output and the powers are not forwarded to the…
takezo
  • 101
  • 7
1
vote
1 answer

How do I weld two anchored parts together?

I made an obby stage where there are falling stones and the player has to get through them before they fall on the ground again. But if they get hit from the bottom face of the rock, they will die. If I would use a touch event on the stone, the…
DonutDev
  • 15
  • 6
1
vote
2 answers

how i can make walking vector3 lerping with rotation?

I'm trying to translate this code from luau in Roblox to GDScript in Godot. This WalkingOffset is multiplied by weapon CFrame in luau: local abs=math.abs local sin=math.sin local clamp=math.clamp local tick=100000 --render every…
display
  • 35
  • 3
1
vote
2 answers

Loading Luau script files with the C API

I want to let a third-party develop a Lua script that runs with my C++ application. A script may contain many individual files. To make this safe I use Luau for sandboxing. My C++ application must compile and load the third-party Luau script files…
Rhett
  • 51
  • 1
  • 1
  • 3
1
vote
2 answers

Lua given table A with metatable B, have functions in B defer to properties in A *before* identically-named properties in B

So i'm making a system that runs through a list of "Tutorial Steps" during a tutorial, in sequence. the tutorial steps could be anything, but to guarantee some shared structure i've made an 'abstract' class TutorialStep. each unique type of tutorial…
Swanijam
  • 77
  • 1
  • 8
1
vote
0 answers

Cleaner/more performant way to map a point offscreen to the edge of the screen?

so I'm trying to implement a screen waypoint system, like you've probably seen in dozens of different games, where an icon is visible through walls, wherever the target is in the player's viewport. This can be done automatically in my case…
Swanijam
  • 77
  • 1
  • 8
1
vote
1 answer

The returned value shouldn't be nil. But it is. Why?

In my simulator egg hatching system i have a problem. I want to return a random index of a dictionary rank (??) but when I want to clone the returned object value but the it says: Attempt to index nil with "Clone" So the returned Value must be…
1
vote
1 answer

Attempt to index boolean with 'Health'

I made a punch script, with a hitbox part, but it doesn't gives damage and i have an error in the output called "Attempt to index boolean with 'Health'", but the humanoid exists and his properties too, what is happening? Can i fix that? Code…
takezo
  • 101
  • 7
1
vote
1 answer

"attempted to call require with invalid arguments" How to Fix Roblox Studio Luau

I was making an Egg-Open-Gui for a simulator and when I ran the script it always arrored this: Attempted to call require with invalid argument(s) Script Players.Robloxgamer_73738.PlayerGui.Menu.EggScript the so called "Eggscript" is local here…
1
vote
1 answer

How do i get the direction or the position that the character of the Player is looking?

I have a question that I've been wanting to know the answer to for a while. How to get the position and direction the player character is looking? I want to know this because I need to make a system that involves this.
takezo
  • 101
  • 7
1
vote
1 answer

How to make a code that shakes the camera of the player

I tried to make a code that's shake the camera player when a RemoteEvent is fired by a key on the keyboard. But it didn't worked. I tried to use the CameraOffset but didn't worked too. How can i make this code without using the CameraShakeModule???…
takezo
  • 101
  • 7
1
vote
1 answer

Attempt to index nil with humanoid

I tried to apply a Humanoid Description on a player that joined the game but the output gives an error: "Attempt to index nil with humanoid". Heres is the code. game.Players.PlayerAdded:Connect(function(Player) …
takezo
  • 101
  • 7
1
vote
2 answers

How to prevent the Player humanoid to die from a part

I made a pistol that fires a part and if a humanoid touches the part then he takes damage but I don't want the player to die when he touches that part, I already tried using the ~= operator but it didn't work. here is the code local db =…
takezo
  • 101
  • 7
1
2 3
8 9