hello great people hope you are having a great day but can you help me here for a sec i'm making it so if you get a kill a gui get deleted (a gun game) but it gets in the player gui and then it just does not want to delete the gui i made a print function and it prints it so i don't under stand and yes the gui is in the player when i tell the script to delete the gui
here is the script
local Remote = game:GetService('ReplicatedStorage'):WaitForChild('GunClone') Remote.OnServerEvent:Connect(function(player,gun) for _, object in pairs(player.PlayerGui:GetChildren()) do if object.Name == "MainGui" then object:Destroy() else print("No gui") end end
and i have more script under that so i cant close it off here is the FULL script
local Remote = game:GetService('ReplicatedStorage'):WaitForChild('GunClone') Remote.OnServerEvent:Connect(function(player,gun) for _, object in pairs(player.PlayerGui:GetChildren()) do if object.Name == "MainGui" then object:Destroy() else print("No gui") end end local m = player.Character:GetChildren() for i = 1, #m do if m[i].ClassName == "Tool" then m[i]:Remove() end end wait() local ChosenGun = game.ReplicatedStorage:WaitForChild(gun):Clone() ChosenGun.Parent = player:WaitForChild('Backpack') wait(0.1) ChosenGun.Parent = player.Character end)
You are missing a end and a ) to close the OnServerEvent.
local Remote = game:GetService('ReplicatedStorage'):WaitForChild('GunClone') Remote.OnServerEvent:Connect(function(player,gun) for _, object in pairs(player.PlayerGui:GetChildren()) do if object.Name == "MainGui" then object:Destroy() else print("No gui") end end end)
Indentions can really help with avoiding these problems.