GUI not showing up when part is touched using a RemoteEvent

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    :To have the player touch a part, and a gui comes up for only the player who touched the part.

  1. What is the issue? Include screenshots / videos if possible!
    :I keep getting the errors, “FireClient: player argument must be a Player object - Server - shop:5” and, “Players.S_thy.PlayerGui.ShopGUI.MainBackground.LocalScript:17: attempt to index nil with ‘Parent’ - Client - LocalScript:17

image
The script for the shop script in SSS

local RS = game:GetService("ReplicatedStorage")
local open = RS:WaitForChild("ShopEvents"):FindFirstChild("open")
local function cheese(player)
	
	open:FireClient(player)
end

game.Workspace.SwordShop.SwordShopPart:Connect(cheese())

–__—_-
image
Code for the local script:

local Tpart = game:GetService("Workspace").SwordShop:WaitForChild("SwordShopPart")
local RS = game:GetService("ReplicatedStorage")
local open = RS:FindFirstChild("ShopEvents").open --RemoteEvent

local deb = false

local function afafa(hit)
	local deb = false
	if deb == false then
		local deb = true
		local char = hit.Parent
		if char then
			local hum = char:WaitForChild("Humanoid")
			if hum ~= nil then
				print("Opening the Shop Gui")
				script.Parent.Visible = true-- Makes the frame visible
			end
		end
		wait(2.5)
		deb = false
	end
end

open.OnClientEvent:Connect(afafa())

Any help is appreciated!

I see that you haven’t connected your events properly just remove the extra parentheses “()”

I did that, but this error occured: image

Is this supposed to be a .Touched event?

Yes, I forgot to add that in, but there is a .Touched event:

game.Workspace.SwordShop.SwordShopPart.Touched:Connect(cheese)

With a touched event you’ll get the part that touched the part you’re listening to touched events on.

In otherwords, you still need to get the character from that part. But before that you’ll need to make sure the part is a character.

otherPart.Parent:FindFirstChild("Humanoid") that might work. But there’s plenty of other ways to go about it as well.

After you confirm it’s a character you can use GetPlayerFromCharacter from the Players service.

P.S @Extrenious is my student.

2 Likes

Where exactly would I insert that?

here’s a link of documentation of what @T0ny was referring to and a screen shot
https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayerFromCharacter

2 Likes

So there are no errors in the output, but the GUI doesn’t show up.

ServerScriptService Script:

local RS = game:GetService("ReplicatedStorage")
local open = RS:WaitForChild("ShopEvents"):FindFirstChild("open")

local function cheese()
	local Players = game:GetService("Players")
	local part = game:GetService("Workspace").SwordShop:FindFirstChild("SwordShopPart")
	local function onTouched(part)
		local player = Players:GetPlayerFromCharacter(part.Parent)
		if not player then return end
		if player then
			open:FireClient(player)
		end
	end
end

game.Workspace.SwordShop.SwordShopPart.Touched:Connect(cheese)

Local Script:

local RS = game:GetService("ReplicatedStorage")
local open = RS:FindFirstChild("ShopEvents").open --RemoteEvent

local deb = false

local function afafa(hit)
	local deb = false
	if deb == false then
		local deb = true
		print("Opening the Shop Gui")
		script.Parent.Visible = true-- Makes the frame visible
		wait(2.5)
		deb = false
	end
end

open.OnClientEvent:Connect(afafa)

Is the GUI object itself enabled?

Yeah, the GUI is enabled. Let me fiddle around with some of the scripts to see if I can manage to get it working.

You have also defined deb twice in your local script.

1 Like

You have a function within a function. The cheese function is being trigged but your not actually triggering the onTouched.

Rewrite of your serverscript. (Should work)

local RS = game:GetService("ReplicatedStorage")
local open = RS:WaitForChild("ShopEvents"):FindFirstChild("open")

local function cheese(part)
	local Players = game:GetService("Players")
		local player = Players:GetPlayerFromCharacter(part.Parent)
		if not player then return end
		if player then
			open:FireClient(player)
		end
end

game.Workspace.SwordShop.SwordShopPart.Touched:Connect(cheese)
1 Like

Yes this fixed it! Thank you so much for your help and compliance @IEnforce_Lawz @T0ny @Extrenious ^^

2 Likes