Hi. I posted earlier, regarding an issue with the same script I’m bringing up now. My previous problem was solved, however I’ve got an issue with GUI visibility. The crystals move up and down as planned - nothing wrong with that. However, I’ve got an issue with changing the visibility of the text box. It doesn’t show. The only thing being shown in the Dev Console (F9) is shown below:
This is telling me that the script isn’t running past the crystal movement script. There’s probably an easy fix for this, but I’d like to consult the DevForum regardless.
Here’s my setup:
Here’s the LocalScript:
local plr = game.Players.LocalPlayer
local PPS = game:GetService('ProximityPromptService')
local ProximityPrompt = game.Workspace.proxPart
local Activated = false
local function onPromptTriggered(ProximityPrompt, plr)
Activated = true
print('Crystals were activated 1/4')
local Crystal = game.Workspace.Crystal
local Crystal2 = game.Workspace.Crystal2
local startPos = Crystal.Position
local startPos2 = Crystal2.Position
while (true) do
wait()
Crystal.Position = startPos + Vector3.new(0,math.sin(tick()),0)
Crystal2.Position = startPos2 + Vector3.new(0,math.sin(tick()),0)
end
plr.PlayerGui.ScreenGui.TextBox.Visible = true
print('Text visible')
plr.PlayerGui.ScreenGui.TextBox.Text = 'You activated the crystals! Only 3 more left...'
print('Text Changed')
wait(5)
plr.PlayerGui.ScreenGui.TextBox.Visible = false
print('Text hidden')
end
PPS.PromptTriggered:Connect(onPromptTriggered)
If someone could let me know what went wrong and how to fix it, that’d be greatly appreciated. Thanks.
The problem is, nothing after the while loop will run, since it never breaks or ends. If you want to run the while loop synchronously, try putting it in task.spawn() or at the end of the code.
How to use task.spawn():
task.spawn(function()
– Do something here
end)