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

How would I fix this gui to turn visible?

Asked by 8 years ago

So I put my gui in ServerStorage so it wouldn't go into the PlayerGui automatically.

If this way is more work, I could provide a script on my attempt to access it through the PlayerGui. My only problem is that players will have other names then 'Player1'

so basically they step on a brick (end of the level) then this gui shows up and tells them they will be moved to the next level in 5 seconds (Already scripted)

local debounce = true
local plr = game.Players.LocalPlayer

script.Parent.Touched:connect(function(plr)
    local gui = game.ServerStorage.EndLevels
    if debounce == true then
        local guicopy = gui:Clone()
        guicopy.Parent = plr.PlayerGui
        debounce = false
    end
end)

Error: > 10:26:55.277 - PlayerGui is not a valid member of Part 10:26:55.280 - Script 'Workspace.Level1.Ground.Script', Line 8 10:26:55.298 - Stack End

Any help?

If you need more info, just comment and i'll reply

0
Is this filtering enabled? Scarious 243 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

LocalScripts don't work in Workspace
Hey there, you look lost.

Your script will only error in Studio, because that's the only place where LocalScripts will run in Workspace. Whilst that's nice, it also won't work in online mode full-stop so that's going to be an issue for you. Beggars can't be choosers.

In the event that this is not a LocalScript, this will error on trying to access LocalPlayer regardless. Pick your poison.


You overwrote plr
Haven't I seen you before?

You define plr as the LocalPlayer at the start of the script, however you make your function argument to be named plr, which overwrites it. Make a choice of which one you need to be keeping, and make sure that your naming conventions don't overlap.


You never checked what is causing Touched
Baseplates are Parts too.

Your connection will try to do the body whenever just about anything touches it, because you don't check if the part in the argument belongs to a Character. At that, you also don't check who it belongs to.

0
Whoops I totally forgot to put my humanoid check ;-; DeveloperSolo 370 — 8y
0
Yea that fixed it. Thanks ;-; DeveloperSolo 370 — 8y
0
You forgot a lot by the looks of it. User#6546 35 — 8y
Ad

Answer this question