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.
local plr = game.Players.LocalPlayer local hum = plr.Character.Humanoid print("Running") script.Parent.Touched:Connect(function(hit) print(hit) if hit.Parent:WaitForChild("Humanoid") == true then print("bruh") end 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
local plr = game.Players.LocalPlayer local hum = plr.Character.Humanoid print("Running") script.Parent.Touched:Connect(function(hit) print(hit) if hit.Parent:WaitForChild("Humanoid") ~= nil then print("bruh") end 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.
local plr = game.Players.LocalPlayer local hum = plr.Character.Humanoid local part = workspace.(PART) print("Running") part.Touched:Connect(function(hit) print(hit) if hit.Parent:WaitForChild("Humanoid") == true then print("bruh") end end)