Still have questions? Join our Discord server and get real time help.
Log in to vote

Script Shows GUI on the first Chest, but then doesnt show gui on any other chests, why?

Asked by
AIetheo 236 Moderation Voter
1 year ago

My Problem is that when i spawn in, it spawns the chests, then I go up to the first one and it shows the gui. But when I walk Up To The Second Chest it does not show the gui for some reason but i can go back to the first chest and it will show the gui again.

First Chest:

Second Chest:

Explorer Images: Chest Location Gui Location


local Chests = workspace.Chests
local Range = 10
local P = game.Players.LocalPlayer
local C = P.Character or P.CharacterAdded:Wait()
local Hb = game:GetService("RunService").Heartbeat

function Check()
    for i,v in pairs(Chests:GetChildren()) do
        if (v.Hitbox.Position - C.PrimaryPart.Position).Magnitude <= Range and not v.Openers:FindFirstChild(P.Name) then
            local Pos = workspace.CurrentCamera:WorldToScreenPoint(v.Hitbox.Position)
            script.Parent.Open.Position =,Pos.X,0,Pos.Y,0)
            script.Parent.Open.Visible = true
            if script.Parent.Open.Visible then
                script.Parent.Open.Visible = false


1 answer

Log in to vote
Answered by 1 year ago

Use ContextActionService to bind an action to the 'E' key when the player gets close to the chest, then use ContextActionService: SetImage to have the GUI appear (, then when the player is too far from the chest, unbind the action from the key and rebind it again when the player is close enough to a chest. Just use remote events when the player presses the 'E' from a local script and then fire the server. I hope it helps!


Answer this question