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

LocalScript in GUI working fine in studio, but doesnt work at all in-game..?

local npc1 = game.Workspace.NPCs:WaitForChild("npc1")
local messageGUI = game.Players.LocalPlayer.PlayerGui:WaitForChild("Message1")
local modules = game.ServerScriptService:WaitForChild("modules")

npc1.Hitbox1.ClickDetector.MouseClick:Connect(function()
	if npc1.Hitbox1.ClickDetector.MaxActivationDistance == 32 then
		messageGUI.Frame.Visible = true
		messageGUI.Frame1.Visible = true
		messageGUI.Frame1.TextLabel.Text = modules.npc1Messages.text1
	end
end)

It seems to work perfectly in studio, but in game is another story. I've tried everything I know that could solve this, yet always end up in the same spot. What am I doing wrong?

1 comment

0

What script type is it

1 answer

Add this at the very top of your script

repeat wait() until game.Players.LocalPlayer.Character ~= nil
wait (2)

hope this helps

3 comments

0

no

0

Please refrain from giving irrelevant code, you've been doing this for a while now.

0

it works for me

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