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)
Edit: After some careful examination of my code and with some help from the folks at ScriptingHelpers, I changed it to where the insertion and deletion of the billboard GUI is handled by the client. Thank you everyone who responded in an attempt to help.