Hi, So I'm unsure if this post counts on this website as It's about code, so let me know if it's unwelcome. Anyways, I have an issue with Roblox studio in general, The output bar is printing no errors or print statements from local scripts. It prints just fine from a Server script, as I've tested that. Here is the code I'm running, nothing is printing or giving me errors.
1 | local plr = game.Players.LocalPlayer |
2 | local hum = plr.Character.Humanoid |
3 | print ( "Running" ) |
4 | script.Parent.Touched:Connect( function (hit) |
5 | print (hit) |
6 | if hit.Parent:WaitForChild( "Humanoid" ) = = true then |
7 | print ( "bruh" ) |
8 | end |
9 | end ) |
How can I fix this so I get output from a local script? Thanks!
I should mention that I am in collaborative editing, I'm the owner. This has happened to me before in solo editor games so I don't think that's the issue, but I figured I'd add that here.
Local scripts located in the workspace do not run. You gotta put it somewhere in the player.
Use ~= nil instead of == true
1 | local plr = game.Players.LocalPlayer |
2 | local hum = plr.Character.Humanoid |
3 | print ( "Running" ) |
4 | script.Parent.Touched:Connect( function (hit) |
5 | print (hit) |
6 | if hit.Parent:WaitForChild( "Humanoid" ) ~ = nil then |
7 | print ( "bruh" ) |
8 | end |
9 | end ) |
I'm not sure if this is the issue, but the local script with the .Touched event MUST be a descendant of the player. If the script with .Touched is inside the part then it wont work. I recommend putting this script inside of the player, and then referencing the part seperately.
01 | local plr = game.Players.LocalPlayer |
02 | local hum = plr.Character.Humanoid |
03 | local part = workspace.(PART) |
04 | print ( "Running" ) |
05 | part.Touched:Connect( function (hit) |
06 | print (hit) |
07 | if hit.Parent:WaitForChild( "Humanoid" ) = = true then |
08 | print ( "bruh" ) |
09 | end |
10 | end ) |