Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

function does not see custom gui?

Asked by 5 years ago
Edited 5 years ago

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)

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago

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.

0
no sorry i have more script under this lines so i can't close it off yet GamerJanko 50 — 5y
Ad

Answer this question