#How do i make the screengui enabled / visible?
136 messages · Page 1 of 1 (latest)
oh
the problems on line 4
local screengui = game.Players.LocalPlayer.PlayerGui.ScreenGui
try that
im getting "attempt to index nil with "playergui" using that part
local scripts only play the animation locally
also the tool is stored in the players backpack
** You are now Level 3! **
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
1 second
you need to use the Players.PlayerAdded event
so it has the correct player
yeah but how would that work
** You are now Level 1! **
wouldnt the event work each time a player joins
since its a global script
it says "fires when a player enters a game"
you would need to use that event to get the player
so how do i do that
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)
any errors?
no
send your script
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)```
the tool is the child
if you want it for a specific tool you can use if tool.Name == 'whatever the name is' then
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
aight
it doesnt work though
i'll test it rq
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```
** You are now Level 2! **
its because its in the tool.equipped thing
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
game.Players.PlayerAdded:Connect(function(player)
this line defines the player
in the function
why isnt it working tho
whatd i mess up
how you got the player
and screengui
but i was telling you to get it in the wrong way
so whats the right way
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
ill send you your original script
** You are now Level 4! **
wait
you dont have to
i didnt save roblox studio
i can just close without saving
it worked lol
i'm now going to spend my entire morning testing this shit
i have a feeling it will
i think it will for some reason
im in the game
aight
well 2
so first
wait can we move to dms im talking on 1/3 of my screen
its annoying as hell
done
** You are now Level 3! **
wait how i do that lol
uhhh