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

How do I make a part when touched will disappear only on your screen ?

Asked by 5 years ago
Edited by User#5423 5 years ago
01local db = true
02script.Parent.Touched:connect(function(hit)
03    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
04        if db == true then
05            db = false
06            script.Parent.Transparency = 1
07            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
08            player.leaderstats.Bricks.Value = player.leaderstats.Bricks.Value + 1
09            script.Sound:Play()
10            wait(1)
11            script.Parent:Remove()
12        end
13    end
14end)

So this is the script I made but I dont know how to make it only disappear on your screen but everybody can go get it

1
Try putting that code in a LOCALSCRIPT. I haven't scripted in a while and know nothing about FE, but give that a try. Infocus 144 — 5y
0
edit:- codeblock User#5423 17 — 5y
0
I tryed that but doesnt work Dinosaur201111 7 — 5y
0
Did you want it to disappear only for you? Theres nothing wrong with your code Infocus 144 — 5y
0
I want to make it disappear only for me I put it in a script but it shows up for everyone when I put it in local script it wont do anything Dinosaur201111 7 — 5y

2 answers

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
5 years ago

Use Remote Events to do this. You make a client remoteevent and connect your script to that user. Probably using this script below

Localscript in StarterGui

1game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(part, method)
2    if part and method == "invis" then
3        part.Transparency = 1
4        part.CanCollide = false
5    elseif part and method == "show" then
6        part.Transparency = 0
7        part.CanCollide = true
8    end
9end)

Server Script in Workspace or ServerScriptService

1script.Parent.Touched:Connect(function(plr)
2    if plr and plr.Parent:FindFirstChild("Humanoid') then
3        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
4 
5        game.ReplicatedStorage.RemoteEvent:FireClient(player, script.Parent, "invis")
6    end
7end)
Ad
Log in to vote
0
Answered by
b2lego 30
5 years ago

make sure that the local script is in game.Players.StarterPack.StarterScripts or something like that because that way, it will only apply to the player

Answer this question