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

My simple hotbar and power system isn't toggling visibility?

I have a game that lets you choose a power and battle other players with it. It's really simple, but for some reason, it still doesn't work. All in all the scripts combined hide all of the hotbars, then gives you a menu to select a power from.

Once you do, it finds the hotbar for that specific part and makes it visible. Then once the player dies it hides all hotbars and repeats the process. That's what it's supposed to do, but it does nothing. You can select your power but the hotbars don't change for some reason:

P.S. I get an error for line 12 of the main script saying: Died is not a valid member of Player "Players.PWTR1CK"

Main Script

local Menu = script.Parent
local Quirk = game.StarterGui.Quirk

local Player = game.Players.LocalPlayer

local Hotbars = game.Players.LocalPlayer.PlayerGui.PlayerGUI:GetChildren()
Hotbars.Visible = false

Menu.Visible = true
Quirk = nil

Player.Died:Connect(function()
	Quirk = nil
	Menu.Visible = true
	Hotbars.Visible = false
end)

Button Script (that you click for your power)

local Menu = game.Players.LocalPlayer.PlayerGui.Menu.Frame
local Button = script.Parent
local Quirk = game.StarterGui.Quirk

Button.MouseButton1Click:Connect(function()
	Menu.Visible = false
	Quirk = Button.Text
	local FindHotbar = game.Players.LocalPlayer.PlayerGui.PlayerGUI:FindFirstChild(Quirk)
	if FindHotbar then
		FindHotbar.Visible = true
	end
end)

1 answer

Players do not die, their characters do. Instead of listening to Player.Died listen to Player.Character.Humanoid.Died. The error that you are getting is telling you that Player.Died is not a valid method.

Player

Humanoid

2 comments

0

I've changed it to exactly what you said and now I get this error: Humanoid is not a valid member of Model "Workspace.PWTR1CK"

0

Player.Character:WaitForChild("Humanoid"), that should work. Usually if you don't find the humanoid in a character that means the script ran too fast.

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