Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

is it possible to make certain parts invisible only to certain players?

Asked by
shackfu 14
5 years ago
Edited 5 years ago

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

0
Post the script DinozCreates 1070 — 5y
0
In short, yes. This is also not how you're supposed to ask questions here. SaltyPotter 362 — 5y
0
A wall of text with no end and no code is not going to get an answer quickly or likely at all. DinozCreates 1070 — 5y
0
ok i will add the code to the question shackfu 14 — 5y
View all comments (2 more)
0
Put it in a local script zboi082007 270 — 5y
0
i did that with the script under the "area" block and i didn't get an error message but it didn't seem like much happened so i'm not sure if it worked or not shackfu 14 — 5y

Answer this question