Button Delete in Studio but doesnt delete in game

Hello Iam Sam
iam still Continue with my allies system

and i have found an error that idk how to patch it

Its about a script use to delete a button studio and worked fine in studio tho
But in game it doesnt delete it but there to error in developer console too

Studio
as you can see it find the button classname and delete it

Game

Script
Local script (in starterplayerscript)


local name = player.Name
for i,target in pairs(player.PlayerGui:WaitForChild("AlliesGui").Frame.NeutralScrolling:GetChildren()) do
	if target.ClassName == "TextButton" and target.Name == name then
		game.ReplicatedStorage.Events.FixBugEvent:FireServer(target)
	end
end
--------------------
Script(in SSS)
game.ReplicatedStorage.Events.FixBugEvent.OnServerEvent:Connect(function(player, target)

print(target.ClassName)

target:Destroy()

end)

If anyone found what is the problem and have a solution i really appriciate it!
Thanks for reading
1 Like

Any reason for you to be sending a remote to the server to delete the buttons? Why not just destroy it on the client and not waste performance on a Remote

for i,target in pairs(player.PlayerGui:WaitForChild("AlliesGui").Frame.NeutralScrolling:GetChildren()) do
	if target.ClassName == "TextButton" and target.Name == name then
        print(target.ClassName)
		target:Destroy()
	end
end
2 Likes

both the same and worked fine tho it just about why it doesnt delete in real game lol

They’re not exactly the same, I believe the server wouldn’t get anything from the remote because the UI is local only, it so it wouldn’t exist on the server. You can’t pass something through a remote if its client/server only.

You should only be doing it on the client anyway, the server should never be dealing with PlayerGui.

yeah so after that i tried your script
both sever and client worked fine on studio too but in game both not working lol

What’s the error message when playing in-game? Would be useful if you share it, thanks.

try removing

and

what works in rs should also work in rp

That sentence isnt in the script lol it just idk how to end the scripting blank