Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

0
You need to send the player through the event and the proper hierarchy is game.Players[player.Name].PlayerGui. Golembyte -5 — 5y
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 Gameplayer365247v2 1055 — 5y

1 answer

Log in to vote
0
Answered by
JakyeRU 637 Moderation Voter
5 years ago

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.

0
ok thanks for the help MPforfun 91 — 5y
Ad

Answer this question