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

How can I make the frame visable?

Basically, when you touch a brick you are supposed to be shown a popup GUI that turns off after 10 seconds, I've looked up multiple tutorials however nothing seems to be working.

The RemoteEvent is named and is in ReplicatedStorage "ShowGui"

The Gui itself is also in Replicated Storage named "PlayerWin"

there is also a local script inside

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
 
local player = Players.LocalPlayer
local GuiWinner = ReplicatedStorage:WaitForChild("GuiWinner")
local playerGui = player:WaitForChild("PlayerGui")
 
local PlayerWin = ReplicatedStorage:WaitForChild("PlayerWin")
PlayerWin.Parent = playerGui
 
local function onWelcomePlayerFired()
	PlayerWin.Frame.Visible = true
	wait(10)
	PlayerWin.Frame.Visible = false
end
 
PlayerWin.OnClientEvent:Connect(onWelcomePlayerFired)

And the brick itself has a script inside as well


local Part = script.Parent

Part.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
                wait(10)
          
                    humanoid.Health = 0
     end
end)

local Players = game:GetService("Players")
 
local GuiWinner = Instance.new("RemoteEvent")
GuiWinner.Parent = game.ReplicatedStorage
GuiWinner.Name = "GuiWinner"
 
local function onPlayerAdded(player)
	GuiWinner:FireClient(player)
end
 
Players.PlayerAdded:Connect(onPlayerAdded)

For any further questions please leave a comment, thanks.

2 answers

You can do this like this: Script in brick:

local Event = game.ReplicatedStorage:WaitForChild("ShowGui")

script.Parent.Touched:Connect(function(hit)
	if debounce == true then
		debounce = false
		if hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) then
			local Player = game.Players:GetPlayerFromChracter(hit.Parent)
			Event:FireClient(Player)
		end
		wait(3)
		debounce = true
	end
end)

Put the GUI in StarterGui to have it given to players on spawn. Local script in GUI:

local Event = game.ReplicatedStorage:WaitForChild("ShowGui")
local Frame = script.Parent:WaitForChild("Frame")
Frame.Visible = false

Event.OnClientEvent:Connect(function()
	Frame.Visible = true
	wait(10)
	Frame.Visible = false
end)

2 comments

0

I got a "GetPlayerFromChracter is not a valid member of Players" error

0

Its a typo. Write GetPlayerFromCharacter instead

  1. u diddnt do anything when the player touched the brick beside setting its health to 0
  2. u diddnt indicate who the player is
  3. u should make a remote beforehand not trough a script this is not neccesary but its easyer this way so make a remote in replicatedStorage


local Part = script.Parent
local Players = game:GetService("Players")
local remote = game.ReplicatedStorage.GuiWinner -- im asumming u named it GuiWinner u will have to change it if u diddnt

Part.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then -- if the thing that touches the part has a humanoid in it it will try to find a player and fire a remote
		local player = Players[hit.Parent.Name] -- Getting the player u are searching for Hit.Parent.Name in game.Player
               GuiWinner:FireClient(player)--Fires the remote
     end
end)

In the local script

  1. u want to make a screengui in playergui u cant see frames or anything if its not in a screengui
  2. u diddnt use a remote to use OnClientEvent u used a ui
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local GuiWinner = ReplicatedStorage:WaitForChild("GuiWinner")
	local Players = game:GetService("Players")
	local player = Players.LocalPlayer
local function onWelcomePlayerFired()
	local playerGui = player:WaitForChild("PlayerGui")
	
	local screengui = Instance.new("ScreenGui") -- making a screen gui
	screengui.Parent = playerGui
	local PlayerWin = ReplicatedStorage:WaitForChild("PlayerWin"):Clone() -- i assume u 	want to use this multiple times so u should probably clone this
	PlayerWin.Parent = screengui -- parenting it to screengui
 	PlayerWin.Frame.Visible = true
    	wait(10)
    	PlayerWin.Frame.Visible = false
end

GuiWinner.OnClientEvent:Connect(onWelcomePlayerFired) -- using a remote to use OnClientEvent

I hope this works i havent test it so im not sure i also hope i explained enoufh :).

2 comments

0

It dosen't work, I didn't show any errors either

0

Try prints and see where the error lays this is good practice for bug finding anyway :)

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