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
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
.