My shop system is a gui that pops up when you talk to an npc. It works when it is first activated, but when I exit the shop and the gui disappear, I cant re enable the gui. Sorry if this is confusing. But anyways the scripts:
Local script in starterplayerscripts
local event = game.ReplicatedStorage.BuyGuns
workspace.Rob.Head.Dialog.DialogChoiceSelected:connect(function(player,choice)
if choice.Name == "Yep!" then
event:FireServer(player)
print("local worked")
end
end)
The server script that receives the remote event located in the npc you talk to:
local event = game.ReplicatedStorage.BuyGuns
function onEvent(player)
print("server worked")
local gui = player.PlayerGui:WaitForChild("ShopSystem")
gui.GunShopCam.Disabled = false
wait(.5)
gui.Enabled = true
end
event.OnServerEvent:Connect(onEvent)
So it works the first time, but when I try to re enter the shop the gui doesn’t pop up.
@drilinz I did what you said but it didn’t work. I remember I put player there because it was erroring, but then I changed stuff around and I just forgot to take that part out.
local replicated = game:GetService("ReplicatedStorage")
local event = replicated:WaitForChild("BuyGuns")
workspace.Rob.Head.Dialog.DialogChoiceSelected:connect(function(player,choice)
if choice.Name == "Yep!" then
event:FireServer()
print("local worked")
end
end)
local event = game.ReplicatedStorage.BuyGuns
function onEvent(player)
print("server worked")
local gui = player.PlayerGui:WaitForChild("ShopSystem")
if gui then
print("gui found") -- prints?
gui.Enabled = false
task.wait(0.5)
gui.Enabled = true
end
end
event.OnServerEvent:Connect(onEvent)