#Beginner Script not working
49 messages · Page 1 of 1 (latest)
script.Parent.Touched:Connect(function(Part)
if Part.Parent:FindFirstChild("Humanoid") then
game.StarterGui.Shop.Frame.Visible = true
end
end)
script ^^
your using startergui, you need to get the players playergui instead
so switch it from StarterGui to PlayerGui
** You are now Level 3! **
now it says that PlayerGui is not a member of game
try doing
local Player = game.Players:GetPlayerFromCharacter(Part.Parent)
then get the PlayerGui from the Player
ok, ill try that
since its only getting the Gui not the PlayerGui
and do a Debouce
so its not opening
i was gonna add that after I got it to open
so do if NotOpen then
it will close the Frame
local Open = false
script.Parent.Touched:Connect(function(Part)
if Part.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Part.Parent)
if Open then
Open = true
local PlayerGui = Player:FindFirstChild('PlayerGui'):FindFirstChild('ScreenGui')
local Frame = PlayerGui.Frame
Frame.Visible = true
task.wait(2)
Open = false
Frame.Visible = false
end
end
end)```
did you jsut make the script for me?
ye
should I replace ScreenGui with what I have it named as?
it still isnt working
I probably made something wrong
nothing is showing up as an error in the output
wait, I might have it
nope
local Open = false
script.Parent.Touched:Connect(function(Part)
if Part.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Part.Parent)
if not Open then
Open = true
local PlayerGui = Player:FindFirstChild('PlayerGui')
local ScreenGui = PlayerGui:FindFirstChild('ScreenGui')
if ScreenGui then
local Frame = ScreenGui.Frame
Frame.Visible = true
end
end
end
end)
script.Parent.TouchEnded:Connect(function(Part)
if Part.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Part.Parent)
if Open then
Open = false
local PlayerGui = Player:FindFirstChild('PlayerGui')
local ScreenGui = PlayerGui:FindFirstChild('ScreenGui')
if ScreenGui then
local Frame = ScreenGui.Frame
Frame.Visible = false
end
end
end
end)```
now retry then edit it so its going to set
and u can change this linelua if ScreenGui then
to lua if PlayerGui and ScreenGui then
on both
its working now
but
when im walking on the part, the gui is flashing, but if I stand still it works
so its working but not visually apealing
you dont have to help me anymore if you dont want to
I’m going to fix it for u to make it not flash for each step on part
local Open = false
script.Parent.Touched:Connect(function(Part)
if Part.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Part.Parent)
if not Open then
Open = true
local PlayerGui = Player:FindFirstChild('PlayerGui')
local ScreenGui = PlayerGui:FindFirstChild('ScreenGui')
if ScreenGui then
local Frame = ScreenGui.Frame
Frame.Visible = true
end
end
end
end)
script.Parent.TouchEnded:Connect(function(Part)
if Part.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Part.Parent)
if Open then
Open = false
local PlayerGui = Player:FindFirstChild('PlayerGui')
local ScreenGui = PlayerGui:FindFirstChild('ScreenGui')
if ScreenGui then
local Frame = ScreenGui.Frame
Frame.Visible = false
end
end
end
end)```
should I change if Screen Gui to if Screen Gui and PlayerGui??
yeah
but for if Screen Gui then
like on line 10
also now it closes after like 3 sec
Just add a else