Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How Do I Clone Gui into PlayerGui with Filtering Enabled?

I hate to make such a lengthy post, but I am completely stumped and want to make sure I get my idea across.

I have gotten the current version of the script to work in Studio / without FE. Whenever I test, it simply does not work. I have watched and tried multiple tutorial methods of implementing remote functions / events, but none of them seem to work for my case.

The current issue is a Gui, a timer, is supposed to appear and countdown to 0 for players to be ready for an incoming attack. As stated earlier, it works fine in studio, but the Gui will not clone with FE. I am fairly certain the issue lies within using LocalPlayer. I also am fairly certain that this cannot be fixed, and must be rewritten, as I am using repeat and not a function.

Relevant Code (This script is longer, but only this part is the current issue):

wait(1)
print("Script Running")

TIMER = game.ReplicatedStorage:WaitForChild("TIMER")

repeat 
print("Engine Start")
script.Break.Value = 1
wait(1)

TIMER:clone().Parent = game.Players.LocalPlayer.PlayerGui

wait(10)
game.Soundscape.Ticking:Stop()
game.Players.LocalPlayer.PlayerGui.TIMER:remove()
script.Break.Value = 0
--.
--..
--...script is longer, but irrelevant

Script is in ServerScriptService, TIMER is in ReplicatedStorage

OUTPUTS:

Working Output:

Script Running
Engine Start
Dog Spawned

Broken Output:

Script Running
Engine Start
20:16:31.395 - ServerScriptService.ENGINE:19: attempt to index field 'LocalPlayer' (a nil value)
20:16:31.397 - Stack Begin
20:16:31.397 - Script 'ServerScriptService.ENGINE', Line 19
20:16:31.398 - Stack End

These lines numbers won't match up as I removed cluttering irrelevant code. But it should be from TIMER:clone().Parent = game.Players.LocalPlayer.PlayerGui.

If I left anything out, let me know and I will be sure to update this post.

5 comments

0

Don't use :remove use :Destroy

0

can you clearify a bit more, like what is "TIMER" and the scripts are confusing

0

also :clone() is decaperated, use :Clone()

0

if its a script and not local then use local player = game.Players.PlayerAdded:Connect(function(player)

0

i dont think you can put a event connecting to a function inside a variable

2 answers

✓ Accepted answer

Just put this into a LocalScript and you problem may be fixed, reply to this if it does not.

1 comment

0

I think putting it into a LocalScript is a point in the correct direction, but I just don't understand remote events and functions. I'm going to continue my research and see if I can muster a fix myself. Thank you all for your replies.

wait(1)
game.Players.PlayerAdded:Connect(function(player)
print("Script Running")

TIMER = game.ReplicatedStorage:WaitForChild("TIMER")

repeat 
print("Engine Start")
script.Break.Value = 1
wait(1)

TIMER:clone().Parent = player.PlayerGui

wait(10)
game.Soundscape.Ticking:Stop()
player.PlayerGui.TIMER:remove()
script.Break.Value = 0
end)
--.
--..
--...

should work... maybe idk

This discussion is preserved as it was. New answers, comments, and votes are closed.