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

Making a Gui appear after a player touches it using remote events?

ok so im making a shop and the player has to step on this part in the workspace and that acctivates a remote event stored in replicated storage and then i have a script that on the activation that will make the gui visible. but it is not working here are the scripts

script in a part in the workspace: script.Parent.Touched:Connect(function(hit)

if hit.Parent:FindFirstChild("Humanoid") then

local player = game.Players:GetPlayerFromCharacter(hit.Parent)

game.ReplicatedStorage.OpenShop:FireClient(player)

end

end)

script in the script service detecting the remote event and making gui apear

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local OpenShop = ReplicatedStorage.OpenShop

OpenShop.OnServerEvent:Connect(function()

game.player.ScreenGui.PlayerUI.GameShopFrame.Visible = true

end)

dont know how to fix this because im pretty bad at scripting

2 comments

0

You need to send the player through the event and the proper hierarchy is game.Players[player.Name].PlayerGui.

0

why r u making this with a remote event? making it with remote event is like saying "i want everyone to see this change", just use a local script on it that gives the gui

1 answer

✓ Accepted answer

The Script in the Part:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		game.Players:FindFirstChild(hit.Parent.Name).PlayerGui.ScreenGui.Frame.Visible = true
	end
end)

-- game.Players:FindFirstChild(hit.Parent.Name).PlayerGui.YourGuiName.SomeFrame.Visible = true

You don't need to use a RemoteEvent. You can do it dirrectly from the Server. Here is your Error: game.player.ScreenGui.PlayerUI.GameShopFrame.Visible = true It should be: game.Players[player].PlayerGui.ScreenGui.PlayerUI.GameshopFrame.Visible = true

In the first line, we create a Function that will fire when the player touches that brick. Then, it checks if it is a Humanoid. (hit.Parent.Humanoid - hitpart(leg, hand, head, torso etc .PlayerModel.Humanoid). If true then it makes the Frame visible dirrectly from the PlayerGui.

1 comment

0

ok thanks for the help

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