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

Why does this local script only work in studio but not the actual game?

When I play the game in studio, the local script works perfectly fine. But, in the actual game it doesn't work. Also, the local script is in a ScreenGui, and the ScreenGui is activated when you click on a certain part. Heres the scripts:

Script that activates the GUI when you click on a certain part:

function boop(Player)
	if not Player.PlayerGui:FindFirstChild("Gui") then
		local gui = script.Gui:clone()
		gui.Parent = Player.PlayerGui
		gui.LocalScript.Disabled = false
	end
end
script.Parent.ClickDetector.MouseClick:connect(boop)

Local Script:

local save = script.Parent:WaitForChild("save")
local glitch = script.Parent.glitchbackground:WaitForChild("glitch")
local glitchbackground = script.Parent:WaitForChild("glitchbackground")
local static = glitch.Static

script.Heal:Play()

wait(5)
save.ImageTransparency=1
glitchbackground.ImageTransparency=0
glitch.ImageTransparency=0
script.Sound:Play()

wait(2)
script.Static:Play()
wait(0.5)
script.Static.Volume=0.1
static.ImageTransparency=0.9
wait(0.5)
script.Static.Volume=0.2
static.ImageTransparency=0.8
wait(0.5)
script.Static.Volume=0.3
static.ImageTransparency=0.7
wait(0.5)
script.Static.Volume=0.4
static.ImageTransparency=0.6
wait(0.5)
script.Static.Volume=0.5
static.ImageTransparency=0.5
wait(0.5)
script.Static.Volume=0.6
static.ImageTransparency=0.4
wait(0.5)
script.Static.Volume=0.7
static.ImageTransparency=0.3
wait(0.5)
script.Static.Volume=0.8
static.ImageTransparency=0.2
wait(0.5)
script.Static.Volume=0.9
static.ImageTransparency=0.1
wait(0.5)
script.Static.Volume=1
static.ImageTransparency=0



wait(2)

script.Static:Stop()
static.ImageTransparency=1
save.ImageTransparency=1
glitchbackground.ImageTransparency=1
glitch.ImageTransparency=1
script.Parent.Frame.BackgroundTransparency=0
script.Sound:Stop()

script.Parent.intro.Disabled=false

1 comment

0

What should it do? What is not functioning correctly? That would be very helpful when answering your questions

1 answer

ServerSided scripts can't see something the client replicated, or created.

This means the first, regular script can't find anything inside of the Player's PlayerGui, because it was replicated through StarterGui.

To fix this, I would simple use a Local Script inside the Player's StarterPlayerScripts, or, if you want, the player's PlayerGui.

--// Move this into a Local Script inside StarterPlayerScripts.
function boop(Player)
    if not Player.PlayerGui:FindFirstChild("Gui") then
        local gui = script.Gui:clone()
        gui.Parent = Player.PlayerGui
        gui.LocalScript.Disabled = false
    end
end
script.Parent.ClickDetector.MouseClick:connect(boop)-- You're going to have to re-define the Click Detector you want.

Make sure you use WaitForChild when redefining variables. This is especially important on the client.

For more information about why this problem can occur, read this article on the subject.

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