I'm really new to scripting and I'm trying to do something in my script testing place right now but i can't seem to do it. I have 4 walls at an area and what i'm trying to do is make it so that if you step in between 2 of the walls, the other 2 will disappear so that i can make rooms in which you can look in from outside of them but not see into other areas. In StarterPlayerScripts i have a LocalScript that creates a function ("room") and makes it so that if it equals 1 then it makes 2 walls i want to disappear have their transparencies set to 1 (I would hope that since it's in a LocalScript it only shows up like this for the person who steps in the area, although i kinda doubt that). Then in between the walls i created an invisible brick that, upon being touched, sets the player's room to 1 (to make this part i may or may not have copy-pasted code from this tutorial https://developer.roblox.com/articles/Creating-Traps-and-Pickup). However, i get an error that says "room is not a valid member of Humanoid" when i test it by trying to walk into it. I tried to do it instead by putting a similar kind of script into the StarterPlayerScripts itself so that i could change the variable but nothing happened when I did that. So what I'm asking is 1) the title of this question and 2) how do i change the "room" variable by touching the invisible part?
Now here's the actual code: this is what i used in StarterPlayerScripts -
var room = 0 if room = 1 then game.workspace.model.Wall3.Transparency = 1 game.workspace.model.Wall4.Transparency = 1 end local trapPart = script.Parent local function onPartTouch(otherPart) if otherPart.name = game.workspace.Room1.area room = 1 trapPart.Touched:Connect(onPartTouch)
it's called trapPart because that's how it was in the tutorial that i copied the code from. now here's the code i used in the invisble block
local trapPart = script.Parent local function onPartTouch(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") if ( humanoid ) then humanoid.room = 1 end end trapPart.Touched:Connect(onPartTouch)
of course i could just delete this script if i get the script in StarterPlayerScripts to do it instead