#Remote event part disappearance

291 messages · Page 1 of 1 (latest)

unique ice
#

So one specific person?

radiant relicBOT
#

studio** You are now Level 6! **studio

clever bay
#

You can achieve this with just a simple local script

unique ice
#

"so everyone can experience it"

#

I think i need context lmfao

clever bay
#

Yeah thats a little confusing Lol

modest spruce
#

On one persons screen once they see it and go close to it the part is now invisible/gone

#

and on the other persons screen they still see the part as it's a seperate thing for them

unique ice
#

yeah just use a local script lol

modest spruce
#

it's a remote event?

unique ice
#

no?

modest spruce
#

but yes a local script

#

yeah?

unique ice
#

you dont need a remote event for that

modest spruce
#

Player 1 doesn't go up to the part so they still see it on their screen
Player 2 goes up to the part and they don't see it on their screen

#

Well

#

is it possible for it to be timed?

unique ice
#

timed?

modest spruce
#

like the part show up at a certain time

#

not it being there forever until the player goes up to it

unique ice
#

Im getting confused

modest spruce
#

also yo hello kash

clever bay
#

Vincent do you mean you want a part's visibility to be relative to the player

#

And not the entire server?

modest spruce
#

Yes

#

deadass just realised you're from those developer event videos on youtube

#

good work man

clever bay
#

Okay in that case yes just use a local script to check the part's distance

#

You dont need any remote events or anything

clever bay
modest spruce
#

I don't exactly know how to script it man

#

I build, not script lol

surreal yoke
#

do you want the part to be gone on a player screen when he is near it

modest spruce
#

Yeah

clever bay
#

Its not a problem the first step to scripting is figuring out the problem and what it requires to solve it

#

Here ill give you a simple script to fix it

surreal yoke
#

Do you want to learn coding or do you just want the code

clever bay
#
local RunService = game:GetService("RunService")

local character = script.Parent
local root = character:WaitForChild("HumanoidRootPart")

--This is the part you want to make transparent
local part = workspace.Part

RunService.RenderStepped:Connect(function()
    local distance = (part.Position - root.Position).magnitude

    if distance <= minimumDistance then
      part.Transparency = 1
    else
      part.Transparency = 0
    end
end)

Put this script in StarterCharacterScripts

#

Youll have to change the part variable yourself

modest spruce
#

Thanks kash

clever bay
#

Np

#

This should give you a basic idea of how to do it

#

The rest is on you

surreal yoke
#

do you want the part to be gone or invisible?

modest spruce
#

Invisible

surreal yoke
#

ah ok

modest spruce
#

also @clever bay one last question

surreal yoke
#

@clever bay you know that you didnt define minimumDistance

modest spruce
#

How would I make it on a cooldown so it only shows up on a certain time base?

sour lance
#

Make a local script that calculates the distance between the part and the HumanoidRootPart of the player, and if a certain distance is met, change the transparency to 0.

modest spruce
modest spruce
#

Can I get more context on that

sour lance
#

Which part

clever bay
modest spruce
#

debounce

sour lance
modest spruce
#

is it also possible to make it for a model and not a part?

sour lance
#

E.g.:

local debounce = false
local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(input, gp)
  if gp then return end

  if debounce == false then
    -- LOGIC
    debounce = true
  end
end)
modest spruce
#

In best of respect I have no idea what any of that means

sour lance
modest spruce
#

so

#

rename every part/model?

#

to " Part " ?

sour lance
# modest spruce In best of respect I have no idea what any of that means

When a player presses a button, the uis.InputBegan runs the function connected to it, checks if the player is currently typing in chat if gp then return end and if hes not, then it proceeds to check if the debounce value is set to false, if yes then it does its thing and after its done it sets debounce to true, so the process can go again.

sour lance
#
for _, v in iparis(yourModel:GetChildren()) do
  v.Transparency = 0
end
#

What this does it it goes through every child in the model, and sets its transparency to 0

modest spruce
#

Alright

surreal yoke
#

this may be too much information for him 💀

sour lance
#

If you have something else than a part in your model, you better use a checkpoint if current child is in fact a part

modest spruce
#

yeah bro my brain isn't working

sour lance
#

Look

#

for i , v - i stands for index, which is the order number and v stands for value, which is the specific part

surreal yoke
#

Beginner's Roblox Scripting Tutorial #1 - Roblox Studio Basics (Beginner to Pro 2019)

Link to Beginner's Tutorial Series:
https://www.youtube.com/playlist?list=PLhieaQmOk7nIfMZ1UmvKGPrwuwQVwAvFa

Link to download Roblox Studio:
https://www.roblox.com/create

Social Media:
https://twitter.com/realtapwater
https://instagram.com/realtapwater

New...

▶ Play video
modest spruce
#

thanks bro

sour lance
#
Model
  Child1 -- A part
  Child2 -- A bool value
  Child3 -- another part
#

If your model looks like this and you run the function it will output as so

surreal yoke
#

sergius this is too much for him

modest spruce
#

why is child 2 a bool value and not a part?

#

dudeee

sour lance
#
Model
  Child1 -- i will be 1, v will be this part
  Child2 -- i will be 2, v will be this specific bool value
  Child3 -- i will be 3, v will be this specific part
sour lance
modest spruce
#

i see

sour lance
modest spruce
#

yes

surreal yoke
#

these can be anything he tries to say

modest spruce
#

just a tad

sour lance
#

Then I suggest watch tutorials

#

later

modest spruce
#

I have been

sour lance
#

Reading Roblox docs

#

Checking the developer forum

modest spruce
#

thanks bro

sour lance
#

3 basic sources

#

Yw

modest spruce
#

is it possible to get like

#

the script on it?

sour lance
#

wdym

modest spruce
#

the main reason for this thread

surreal yoke
#

you want the code?

modest spruce
#

yes please bro

sour lance
#

I don't usually do this but for you I will

modest spruce
#

Thank you

#

if it's possible for a model

#

character model

sour lance
#

Wdym

#

You want the character to dissapear?

modest spruce
#

Yeah

#

for a horror game

sour lance
#

But like, an NPC?

modest spruce
#

Yes

sour lance
#

When the player gets too close to it, the NPC character dissapears?

modest spruce
#

yep

sour lance
#

And it's a multiplayer game?

modest spruce
#

with a cooldown if possible so it doesn't just reappear

#

Yes

surreal yoke
#

you want the Npc invisible or gone?

sour lance
#

Instead of dissapearing forever

modest spruce
#

Yeah

#

invisible npc, no collision (collision is off topic but you know)

surreal yoke
#

should he reapear after a while or never been touched again

modest spruce
#

re appear

#

collision will always be off for that last part if thats what u meant

surreal yoke
#

should he have collision when he is visible

modest spruce
#

no

#

no collision whatsoever

surreal yoke
#
local RunService = game:GetService("RunService")

local character = script.Parent
local root = character:WaitForChild("HumanoidRootPart")
local minimumDistance = 30

--This is the part you want to make transparent
local part = workspace.PutPartNameHere
part.CanCollide = false

RunService.RenderStepped:Connect(function()
    local distance = (part.Position - root.Position).magnitude

    if distance <= minimumDistance then
        part.Transparency = 1
    else
        part.Transparency = 0
    end
end)
modest spruce
#

thank you bro

#

does it need to be in characterscript

surreal yoke
#

yes

#

put it in StarterCharacterScript

#

s

modest spruce
#

Doesnt work

#

I mean for a default r6 model

surreal yoke
#

ah

sour lance
#

Aight

sour lance
#

Wtv

#

here

#
local rs = game:GetService("RunService")

local plr = game.Players.LocalPlayer
local char = script.Parent
local tooClose = false

local model = game.Workspace.Rig -- Change rig to your NPC model
local maxDis = 10 -- If player is closer than this many studs to the model, it dissapears
local maxTime = 5 -- How much time for the player has to be away in order for it to reappear

rs.Heartbeat:Connect(function()
    local distance = (model.HumanoidRootPart.Position - char.HumanoidRootPart.Position).Magnitude

    if distance < maxDis then
        tooClose = true
        for _, v in pairs(model:GetDescendants()) do
            if v:IsA("MeshPart") or v.Name == "face" then
                v.Transparency = 1
            end
        end
    else
        if tooClose == true then
            task.wait(maxTime)
            for _, v in pairs(model:GetDescendants()) do
                if v:IsA("MeshPart") or v.Name == "face" then
                    v.Transparency = 0
                end
            end
            tooClose = false
        end
    end
end)
modest spruce
#

Just removed the decal

sour lance
#

It works for me, so it should work for you

#

It's a local script in starterCharacter

modest spruce
#

Thank you, I'll check in just a moment

#

also thanks for the desc parts

#

I don't wanna sound crazy or what not but it's not working

#

at least for me

#

@sour lance

sour lance
#

Did you put a local script in StarterCharacter and paste it in it?

#

And u changed the local model to your model?

surreal yoke
#
local RunService = game:GetService("RunService")

local character = script.Parent
local root = character:WaitForChild("HumanoidRootPart")
local minimumDistance = 15

-- Reference the model you want to make transparent
local model = workspace.Dummy
local parts = model:GetDescendants()

RunService.RenderStepped:Connect(function()
    local distance = (model.PrimaryPart.Position - root.Position).magnitude

    for _, part in ipairs(parts) do
        if part:IsA("BasePart") then
            if distance <= minimumDistance then
                part.Transparency = 1
                part.CanCollide = false
            end
        elseif part:IsA("Decal") or part:IsA("Texture") then
            -- Make Decals and Textures invisible
            if distance <= minimumDistance then
                part.Transparency = 1
            end
        end
    end
end)

Try this and change the model = Workspeace.PutHereYourModel

modest spruce
#

Local model is R6

#

I also did

sour lance
#

Ooooohhh

#

Okay paste in this instead

#
local rs = game:GetService("RunService")

local plr = game.Players.LocalPlayer
local char = script.Parent
local tooClose = false

local model = game.Workspace.Rig -- Change rig to your NPC model
local maxDis = 10 -- If player is closer than this many studs to the model, it dissapears
local maxTime = 5 -- How much time for the player has to be away in order for it to reappear

rs.Heartbeat:Connect(function()
    local distance = (model.HumanoidRootPart.Position - char.HumanoidRootPart.Position).Magnitude
    
    if distance < maxDis then
        tooClose = true
        for _, v in pairs(model:GetDescendants()) do
            if v:IsA("Part") or v.Name == "face" then
                v.Transparency = 1
            end
        end
    else
        if tooClose == true then
            task.wait(maxTime)
            for _, v in pairs(model:GetDescendants()) do
                if v:IsA("Part") or v.Name == "face" then
                    v.Transparency = 0
                end
            end
            tooClose = false
        end
    end
end)
#

now it should 100% work

modest spruce
#

yoo it actually works

#

Appreciate the help big time

sour lance
#

Yw

surreal yoke
#

change the v.Name to ---> v:IsA("Decal") or v:IsA("Texture")

sour lance
#

He doesn't even have a face no more

surreal yoke
#

oh ok

modest spruce
#

Is it possible to add a part to the rig and it still be fine?

#

like a part as a hat (random example)

surreal yoke
#

yes

modest spruce
#

Alright sweeet

#

Thank you all lol

surreal yoke
#

np

radiant relicBOT
#

studio** You are now Level 10! **studio

sour lance
#

bro do u want it to do cool shit

#

@modest spruce

surreal yoke
#

level 10!!!

modest spruce
#

I just want it to be there really, I have a few ideas for it lol

#

but wdym?

sour lance
#

Do you want it to go smoothly in and out

modest spruce
#

ah

#

fade to invisible?

#

that would be awesome bro

sour lance
modest spruce
#

yeah

#

that would be sick

sour lance
#
local rs = game:GetService("RunService")
local ts = game:GetService("TweenService")

local t1 = {}
t1.Transparency = 1

local t0 = {}
t0.Transparency = 0

local tInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

local plr = game.Players.LocalPlayer
local char = script.Parent
local tooClose = false

local model = game.Workspace.Rig -- Change rig to your NPC model
local maxDis = 10 -- If player is closer than this many studs to the model, it dissapears
local maxTime = 5 -- How much time for the player has to be away in order for it to reappear

rs.Heartbeat:Connect(function()
    local distance = (model.HumanoidRootPart.Position - char.HumanoidRootPart.Position).Magnitude
    
    if distance < maxDis then
        tooClose = true
        for _, v in pairs(model:GetDescendants()) do
            if v:IsA("Part") or v.Name == "face" then
                if v.Name ~= "HumanoidRootPart" then
                    local tv = ts:Create(v, tInfo, t1)
                    tv:Play()
                end
            end
        end
    else
        if tooClose == true then
            task.wait(maxTime)
            for _, v in pairs(model:GetDescendants()) do
                if v:IsA("Part") or v.Name == "face" then
                    if v.Name ~= "HumanoidRootPart" then
                        local tv = ts:Create(v, tInfo, t0)
                        tv:Play()
                    end
                end
            end
            tooClose = false
        end
    end
end)
modest spruce
#

maybe if it fades back again after the time out?

#

thank u bro

#

holy shit

sour lance
modest spruce
#

Yeah

#

I mean once it respawns

sour lance
#

Huh

modest spruce
#

like

#

it fades out

#

can we do the same for fading in?

sour lance
modest spruce
#

I have

#

it fades out and stays invisible for a few seconds

#

then it just shows again with no fade in scene

sour lance
#

It does fade in

modest spruce
#

wait

#

nvm

sour lance
#

Cuh

modest spruce
#

Guess my eyes were going insane LOOL

#

thank you though

surreal yoke
modest spruce
#

alr, gonna close thread

sour lance
#

Wait hodl on

modest spruce
#

what's up

sour lance
#

I found a bug where it freaks out

modest spruce
#

oh shit lol

sour lance
#

No wait nvm

#

Lol

#

I think

#

Idk wtv

modest spruce
#

appreciate it though

surreal yoke
#

Ive been helping others for hours now and didn't even tried to touch my own code

modest spruce
#

the respect though

surreal yoke
modest spruce
#

like fr

sour lance
#

Actually hold on, I think I have a better solution to this

surreal yoke
#

this goes on and on lol

modest spruce
#

also can everyone see the R6 model?

#

or is it just for 1 person

surreal yoke
#

if its a local script only for the player

modest spruce
#

alr great

#

appreciate it deadass

sour lance
#

so

#

Wtv

sour lance
modest spruce
#

yeah

surreal yoke
sour lance
modest spruce
#

Yeah that

#

thank you dude

surreal yoke
#

magic

modest spruce
#

is there any issues w the model or are we good to go?

#

just wanna confirm

sour lance
#

As long as the parts you want to be invisile are Parts it will work

modest spruce
#

alr sweeet

#

if I change the head to a mesh that's also fine right

#

cause the head texture is wack

surreal yoke
#

no

sour lance
#

Yeah u just have to

modest spruce
#

uh

sour lance
#
if v:IsA("Part") or v.Name == "face" or v:IsA("Mesh") then
#

add the v:IsA("Mesh")

#

there

modest spruce
#

ty

sour lance
#

so it knows it has to hceck for meshes too

modest spruce
#

do i just add that above the end part?

sour lance
#

theres a line

#

2 actually

modest spruce
#

uh

sour lance
#

just add or v:IsA("Mesh") to both of them

sour lance
#

and bam, the head dissapears aswell

modest spruce
#

alr

#

Thank you

#

not to be an absolute pain in the ass but would you be able to copy paste the code into it

#

I don't wanna ruin any of the code or what not (Wait nvm ty)

sour lance
#
local rs = game:GetService("RunService")
local ts = game:GetService("TweenService")

local t1 = {}
t1.Transparency = 1

local t0 = {}
t0.Transparency = 0

local tInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

local plr = game.Players.LocalPlayer
local char = script.Parent
local tooClose = false

local model = game.Workspace.Rig -- Change rig to your NPC model
local maxDis = 10 -- If player is closer than this many studs to the model, it dissapears
local maxTime = 5 -- How much time for the player has to be away in order for it to reappear

rs.Heartbeat:Connect(function()
    local distance = (model.HumanoidRootPart.Position - char.HumanoidRootPart.Position).Magnitude
    
    if distance < maxDis then
        tooClose = true
        for _, v in pairs(model:GetDescendants()) do
            if v:IsA("Part") or v.Name == "face" or v:IsA("Mesh") then
                if v.Name ~= "HumanoidRootPart" then
                    local tv = ts:Create(v, tInfo, t1)
                    tv:Play()
                end
            end
        end
    else
        if tooClose == true then
            task.wait(maxTime)
            for _, v in pairs(model:GetDescendants()) do
                if v:IsA("Part") or v.Name == "face" or v:IsA("Mesh") then
                    if v.Name ~= "HumanoidRootPart" then
                        local tv = ts:Create(v, tInfo, t0)
                        tv:Play()
                    end
                end
            end
            tooClose = false
        end
    end
end)
modest spruce
#

thanks bro lol

modest spruce
#

yo @sour lance I've been trying to figure out a way to fix the mesh issue but anytime I tried changing the heads mesh it wont work

#

like the head mesh that I've added wont show up

#

my bad for the continue of this though

sour lance
#

Maybe its so big ure inside it and it diesnt render the outside or its super small

#

And just

#

Yk

#

Not visible

#

Also try making new threads for this

modest spruce
#

the size is the same as the head

#

andf alr

#

ty

#

fixed it

#

needs the face thing to be the mesh part instead

#

Gonna close this thread, appreciate the help bro