You can write your topic however you want, but you need to answer these questions:
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.
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”
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())
–__—_-
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())
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)
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)