I'm trying to create a script that inserts a billboard GUI into a character's head and destroys the GUI when it receives a server event. But, the server script that I'm using to destroy the billboard GUI isn't detecting it. I've used print statements to try and debug this and it appears that the .OnServerEvent connection isn't firing at all.
If anyone could help at all, it would be great. Cheers.
Local Script:
local oocGUI = game:GetService('ReplicatedStorage'):WaitForChild('oocGUI')
local rEvent = game:GetService('ReplicatedStorage'):WaitForChild('OOCEvent')
local ooc = false
local player = game:GetService('Players').LocalPlayer
local char = player.Character
local debounce = false
local RESET_SECS = 2
script.Parent.MouseButton1Down:Connect(function()
if not ooc then
if not debounce then
debounce = true
ooc = true
print('ooc Variable set to True')
local cloneOOC = oocGUI:Clone()
print('Clone made')
cloneOOC.Parent = char.Head
print('Clone parent set to character head')
wait(RESET_SECS)
debounce = false
end
else
ooc = false
print('ooc variable set to False')
rEvent:FireServer()
print('RemoteEvent fired')
end
end)
Script:
local RS = game:GetService('ReplicatedStorage')
local rEvent = RS:WaitForChild('OOCEvent')
local textLabel = script.Parent.TextLabel
local gui = script.Parent
rEvent.OnServerEvent:Connect(function()
print('Event received')
if gui.Parent.Name == "Head" then
gui:Destroy()
end
end)

3 comments
Are you ever setting the ooc variable in your local script to true? Because this should definitely be working if you do.
Yeah, on Line 24 the ooc variable is being set to true.
using :Clone() on the client won't copy server scripts. thus the script is not copied into the billboard gui, if you are creating the gui on client, why not destroy it on client too?