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 4 years ago
Edited by User#5423 4 years ago
local db = true
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        if db == true then
            db = false
            script.Parent.Transparency = 1
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            player.leaderstats.Bricks.Value = player.leaderstats.Bricks.Value + 1
            script.Sound:Play()
            wait(1)
            script.Parent:Remove()
        end
    end 
end)

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 — 4y
0
edit:- codeblock User#5423 17 — 4y
0
I tryed that but doesnt work Dinosaur201111 7 — 4y
0
Did you want it to disappear only for you? Theres nothing wrong with your code Infocus 144 — 4y
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 — 4y

2 answers

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 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

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(part, method)
    if part and method == "invis" then
        part.Transparency = 1
        part.CanCollide = false
    elseif part and method == "show" then
        part.Transparency = 0
        part.CanCollide = true
    end
end)

Server Script in Workspace or ServerScriptService

script.Parent.Touched:Connect(function(plr)
    if plr and plr.Parent:FindFirstChild("Humanoid') then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)

        game.ReplicatedStorage.RemoteEvent:FireClient(player, script.Parent, "invis")
    end
end)
Ad
Log in to vote
0
Answered by
b2lego 30
4 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