#How do i make the screengui enabled / visible?

136 messages · Page 1 of 1 (latest)

ornate cove
#

are there any errors?

#

oh

#

the problems on line 4

#

local screengui = game.Players.LocalPlayer.PlayerGui.ScreenGui

#

try that

ember horizon
ornate cove
#

oh

#

its a normal script

ember horizon
#

yeah i tried switching it to a local one now

#

but it isntworking

ornate cove
#

local scripts only play the animation locally

#

also the tool is stored in the players backpack

green zodiacBOT
#

studio** You are now Level 3! **studio

ember horizon
#

so i need to use a normal script

#

how would i reference the playergui with a normal script then?

#

i used this to see if i can rerefence the local player "print("player has been found and its: "..player.Name)"

#

and its giving me none

ornate cove
#

1 second

#

you need to use the Players.PlayerAdded event

#

so it has the correct player

ember horizon
#

yeah but how would that work

green zodiacBOT
#

studio** You are now Level 1! **studio

ember horizon
#

wouldnt the event work each time a player joins

#

since its a global script

#

it says "fires when a player enters a game"

ornate cove
#

you would need to use that event to get the player

ember horizon
#

so how do i do that

ornate cove
#
game.Players.PlayerAdded:Connect(function(player) --when a player joins
  player.CharacterAdded:Connect(function(char) -- when the players character spawns
    char.ChildAdded:Connect(function(child) --when a child is added to the character
      if child:IsA('Tool') then --checks if the child is a tool
        --your script here
      end
    end)
  end)  
end)
#

because its a server sided theres no localplayer

#

so you need use that event to get the players

#

(playeradded)

ember horizon
#

now the screengui

#

oh i can

#

reference it

#

now

ornate cove
#

yes

#

just do player.PlayerGui

#

btw

ember horizon
#

yeah i saw

#

so this is for tools specifically

ornate cove
#

you can change it

#

but this one is only for tools

ember horizon
#

something aint working

#

wait

ornate cove
#

any errors?

ember horizon
#

no

ornate cove
#

send your script

ember horizon
#

local tool = script.Parent.Parent
local animation = script.Animation
local db = false
local swings = 10

tool.Equipped:Connect(function()
    
    local character = tool.Parent
    
    game.Players.PlayerAdded:Connect(function(player) --when a player joins
        player.CharacterAdded:Connect(function(char) -- when the players character spawns
            char.ChildAdded:Connect(function(child) --when a child is added to the character
                
                if child:IsA('Tool') then --checks if the child is a tool
                    
                    local playergui = player.PlayerGui
                    local screengui = playergui.ScreenGui
                    
                    tool.Activated:Connect(function()
                        if db == true  then

                            return

                        else
                            
                            db = true
                            local humanoid = character.Humanoid
                            local animationtrack = humanoid:LoadAnimation(animation)
                            animationtrack:Play()
                            task.wait(1)
                            db = false

                        end
                    end)

                    tool.Handle.Touched:Connect(function(otherPart)
                        if otherPart.Name == "Trunk" then
                            swings = swings-1
                            if swings < 10  then
                                screengui.Enabled = true
                            end
                        end

                    end)
                end
            end)
        end)  
    end)
end)```
ornate cove
#

the tool is the child

#

if you want it for a specific tool you can use if tool.Name == 'whatever the name is' then

ember horizon
#

no, i just want the tool to bewhatever

#

its added

#

for example

#

if someone picks up a differently named thing into their inventory, i dont want to do it again for that tool sepcifically

ornate cove
#

aight

ember horizon
#

it doesnt work though

ornate cove
#

i'll test it rq

ember horizon
#

alright

#
tool.Equipped:Connect(function()
    
    local char = tool.Parent
    
    game.Players.PlayerAdded:Connect(function(player) --when a player joins
        print("player has been found and its: "..player.Name)
        local playergui = player.PlayerGui
        local screengui = playergui.ScreenGui```
green zodiacBOT
#

studio** You are now Level 2! **studio

ember horizon
#

yo

#

the thing doesnt even recognize the player

#

it doesnt print my name

ornate cove
#

its because its in the tool.equipped thing

ember horizon
#

yeah but i used that so i can do tool.parent

#

to get the character

#

i dont see how the script would know which player we're talking about

#

since it just fires when a player joins

#

but like when we reference the player again, how does it know which one we're talking about

ornate cove
#

game.Players.PlayerAdded:Connect(function(player)

#

this line defines the player

#

in the function

ember horizon
#

why isnt it working tho

ornate cove
#

also ive thought of a better way to do it

#

anyway

ember horizon
#

oh alright

#

when i tried to print the player.Name it isnt giving me anything

ornate cove
#

you most did it right earlier

#

i'm just dumb

#

and didnt read your code fully

ember horizon
#

whatd i mess up

ornate cove
#

how you got the player

#

and screengui

#

but i was telling you to get it in the wrong way

ember horizon
#

so whats the right way

ornate cove
#

you can use getplayerfromcharacter()

#

to get the player

ember horizon
#

omfg

#

i was thinking

#

is there a way to do that

#

and i forgot that thing existed

#

ffs

#

i couldve just kept my original script

#

now im lost

ornate cove
#

ill send you your original script

green zodiacBOT
#

studio** You are now Level 4! **studio

ember horizon
#

wait

#

you dont have to

#

i didnt save roblox studio

#

i can just close without saving

ornate cove
#

oh shit

#

you cant enable/disable screen guis from a server script

ember horizon
#

holy shit

#

dont tell me i need a remote event

ornate cove
#

you do

#

but

#

its very simple

ember horizon
#

it worked lol

ornate cove
#

aight then

#

i swear to god you cant

ember horizon
#

wait

#

do u wanna test

#

if your script could enable my gui?

#

in a real game

ornate cove
#

i'm now going to spend my entire morning testing this shit

ember horizon
#

i have a feeling it will

ornate cove
#

it probably wont

#

uhh

ember horizon
#

i think it will for some reason

#

im in the game

ornate cove
#

1 sec

#

gotta login

ember horizon
#

alright so

#

do you mind helping me out with some other thing

ornate cove
#

aight

ember horizon
#

well 2

#

so first

#

wait can we move to dms im talking on 1/3 of my screen

#

its annoying as hell

ornate cove
#

aight

#

also mark this shit as solved

ember horizon
#

done

green zodiacBOT
#

studio** You are now Level 3! **studio

ember horizon
#

wait how i do that lol

ornate cove
#

uhhh