If statement does a stupid and doesn't run part of the code?

so i’ve got this if statement that runs after a remote event

but it’s, really weird

-- theme is a sound
-- script.Parent is a screengui

changeCamera.OnClientEvent:Connect(function()
	renderConnection = rService.RenderStepped:Connect(UpdateCamera)
	
	if not workspace:FindFirstChild("MenuRoom") then
        script.Parent.Enabled = true -- will NOT run
        theme:Play() -- will NOT run
		rStorage.MenuRoom.Parent = workspace -- will run ????
	end
end)

Where is theme located? Sounds don’t play if they aren’t in the workspace, a Part or an Attachment.

Try this:

changeCamera.OnClientEvent:Connect(function()
    print("OnClientEvent fired")
	renderConnection = rService.RenderStepped:Connect(UpdateCamera) -- is rService spelled correctly?
	print(workspace:FindFirstChild("MenuRoom").Name  -- this may not be the correct format, I'm not great at scripting
	if not workspace:FindFirstChild("MenuRoom") then
    print(script.Parent.Enabled)   -- will tell you if it's true, false, or nil
        script.Parent.Enabled = true -- will NOT run
        theme:Play() -- will NOT run
		rStorage.MenuRoom.Parent = workspace -- will run ????
	end
end)

inside the screengui charrrrrrr

So did you read the next thing I typed.
Sounds won’t play from a GUI.

ohhh i read it “are in the workspace …”

mb i was tired

but the sound plays at first, it’s always inside the gui
the gui nor the sound get activated upon that remote event

okay i’m not sure whether this is agood idea or not

but this is what i ended up doing:

changeCamera.OnClientEvent:Connect(function()
	renderConnection = rService.RenderStepped:Connect(UpdateCamera)
	
	if not workspace:FindFirstChild("MenuRoom") then
		rStorage.MenuRoom.Parent = workspace
	end
	
	if plr:GetAttribute("Loaded") == true then -- checks for attribute to prevent the theme playing during loading
		theme:Play()
		gui.Enabled = true
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.