Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this local script show the gui to everyone?

I'm making a loot box and when a player walks near it they can press e to get an item. However, once someone is in the area everyone in the server sees the gui and can press e to get an item. I have this local script under StarterPlayerScripts:

local uis = game:GetService("UserInputService")
local inArea = false
local keyPressed = false--debounce
local player = game.Players.LocalPlayer 
workspace.LootBox1.AREA.Touched:Connect(function()
 inArea = true
    print("entered")
    workspace.LootBox1.Part.BillboardGui.Enabled = true

     uis.InputBegan:Connect(function(input) 
       if input.UserInputType.Name == "Keyboard" and input.KeyCode.Name == "E" and inArea == true and keyPressed == false then
        keyPressed = true
        print("THIS WORKS IF PRINTED")
wait()
game.ReplicatedStorage.CloneTool:FireServer(player)
wait()
keyPressed = false
    end
    end)
    end)

        workspace.LootBox1.AREA.TouchEnded:Connect(function()
            workspace.LootBox1.Part.BillboardGui.Enabled = false
            inArea = false
            print("left")
        end)

What did I do wrong?

1 comment

0

I'm not really sure how to fix this, however I know one way to make sure not everyone in the area can see it but only the people close to the loot box can see it. On the billboardgui of your lootbox, look for the propery named "MaxDistance," and change that to something like 15. I'm pretty sure this changes the amount of studs needed to see the billboard gui.

1 answer

✓ Accepted answer

I think I know a solution to make it local.

Firstly, you will need to have the BillBoardGui inside of the player's PlayerGui, and set it's Adornee to

workspace.LootBox1.Part

Enjoy!

This discussion is preserved as it was. New answers, comments, and votes are closed.