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

Why isnt it when I touch the Block a GUI won't pop-up?

local hitpart = script.Parent
local function onclick(click)
	local h = click.Parent:FindFirstChild("Humanoid")
	if h then
		print('it works')
		local player = game.Players:GetPlayerFromCharacter(click.Parent)
	player.PlayerGui.Song.Frame.Visible = true
	end
end
hitpart.ClickDetector.MouseClick:connect(onclick)

Please help explain where I went wrong.

1 answer

✓ Accepted answer
local hitpart = script.Parent

local function onclick(player)

    print("It Works")
    player.PlayerGui.Song.Frame.Visible = true

end

hitpart.ClickDetector.MouseClick:connect(onclick)

The MouseClick event returns the player, not the character. Hope this helps

1 comment

0

My thing though is why does it find a player why couldn't I just use the script i made since it works if it's a ontouch function

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