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

I'm trying to make a GUI show when you are falling using a script. Can i get help?

So, i'm making a game about skateboarding and when you fall, it plays breathing and heavy wind noises. I'm adding a part to the script that i thought would make the screen border black when you fall, but it doesn't work. Can you help me understand what is going wrong?

The code:

local humanoid = script.Parent
local isFalling = false

humanoid.FreeFalling:connect(function(falling)
	isFalling = falling
	if isFalling then
		game.Workspace.Assets.breathing:Play()
		game.Workspace.Assets.wind:Play()
		script.Parent.Parent.Parent.wind.vignette:Clone()
	else
		script.Parent.Parent.Parent.wind.vignette:Destroy()
		game.Workspace.Assets.breathing:Stop()
		game.Workspace.Assets.wind:Stop()
	end
end)

1 comment

0

You are cloning vignette, you need to set parent. If it's in playergui already enable/disable would be a bettter option

1 answer

✓ Accepted answer

To make this easier for you I will give you to examples. If you are using it in the local script you could clone vignette:

local vignette = game.Workspace.Vignette:Clone() -- Example put your location here
vignette.Parent = game.Players.LocalPlayer.PlayerGui
-- when removing make sure to check if it exists
if game.Players.LocalPlayer.PlayerGui:FindFirstChild("Vignette") then
	game.Players.LocalPlayer.PlayerGui:FindFirstChild("Vignette") :Destroy()
end

-- or if it already exists in player's playergui then you can use this 

game.Players.LocalPlayer.PlayerGui.Vignette.Enabled = true

-- when removing
game.Players.LocalPlayer.PlayerGui.Vignette.Enabled = false

if you are using a normal script you can only clone gui to player's playergui

local vignette = game.Workspace.Vignette:Clone() 
vignette.Parent = player.PlayerGui
-- when removing
if vignette then
	vignette:Destroy()
end

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