#Need help with a script

1 messages · Page 1 of 1 (latest)

midnight swallow
#

im making a new game on roblox and im trying to make my own version of a script that the studio assistant helped me make but its not working the way i want it to , any help?

#

i want to make the text above the portals dissapear depending on how far you are from it

#
local Workspace = game:GetService("Workspace")

local player = Players.LocalPlayer
local portals = Workspace.Portals
local portal1 = portals:WaitForChild("Portal1")
local portal2 = portals:WaitForChild("Portal2")
local portal3 = portals:WaitForChild("Portal3")

local portal1Gui = portal1:FindFirstChild("BillboardGui")
local portal2Gui = portal2:FindFirstChild("BillboardGui")
local portal3Gui = portal3:FindFirstChild("BillboardGui")    

local ACTIVATION_DISTANCE = 75 -- studs
local CHECK_INTERVAL = 0.3 -- seconds between distance checks    
    if not portal1Gui or not portal2Gui or not portal3Gui then
    warn("Could not find BillboardGui on Portals")
    return
end
    
local function getCharacterPosition()
    local character = player.Character
    if character then
        local hrp = character:FindFirstChild("HumanoidRootPart")
        if hrp then
            return hrp.Position
        end
    end
    return nil
end

local function getPortalPosition()
    local portal1Pos = portal1.Position
    local portal2Pos = portal2.Position
    local portal3Pos = portal3.Position

while task.wait(CHECK_INTERVAL) do
    local playerPos = getCharacterPosition()
    local portalPos = getPortalPosition()
    
    if playerPos and portalPos then
        local distance = (playerPos - portal1Pos).Magnitude
        portal1Gui.Enabled = distance <= ACTIVATION_DISTANCE
        local distance = (playerPos - portal2Pos).Magnitude
        portal2Gui.Enabled = distance <= ACTIVATION_DISTANCE
        local distance = (playerPos - portal3Pos).Magnitude
        portal3Gui.Enabled = distance <= ACTIVATION_DISTANCE
    else
        portal1Gui.Enabled = false
        portal2Gui.Enabled = false
        portal3Gui.Enabled = false    
    end
end

end```
#

this is the script i wrote

tough wolf
static zephyr
#

just ever

#

roblox is trying to force AI slop

#

dont use it

candid snow
#

It has helped me build my game, but I reccomend to not become dependant and try to do it by your own, it will feel much more rewarding

static zephyr
#

you never learn with it

#

and the game can fail really easily

candid snow
#

because it has ruined one of my projects, I just use it to read my code, to check what is wrong with it when I cant, like when I put WorkSpace instead of workspace

#

things like that

#

now i gtg goodbye yall

wild root
gleaming cedar
#

Some times you need help from an Ai

static zephyr
#

and honestly if you use an ai for help probably use chatgpt instead