So, I'm trying to do a Gui that shows up to all the players when someone (an HR from my group) clicks another button. I get an error from the Script that is inside of the Gui, that says "Unable to cast value to Object" https://gyazo.com/8d6591d0cd133a22e61f5f0711b0e298
local RemoteEvent = game.ReplicatedStorage.AdvertEvent function Click() local Player = script.Parent.Parent.Parent.Parent.Parent.Name RemoteEvent:FireClient(Player) end script.Parent.MouseButton1Click:Connect(Click)
I have a LocalScript inside StarterPlayer > StarterPlayerScripts > Events > LocalScript that puts:
local AdvertEvent = game.ReplicatedStorage.AdvertEvent local Player = game.Players.LocalPlayer function ShowAdvert() local Gui = game.StarterGui.AdvertGui if (not Player.PlayerGui:FindFirstChild(Gui.Name)) then Gui.Parent = Player.PlayerGui end end AdvertEvent.OnClientEvent:Connect(ShowAdvert)
You can only call FireClient from the server. When the MouseButton1Click event is fired, call FireServer and then from the server, call FireClient.