To put it simply, Fram.Visible is not appearing when I want it to appear. What is wrong with this code?
local gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("buy").Frame
local part = workspace.click.ClickDetector
local Owns = game.Players.LocalPlayer.PlayerGui:WaitForChild("buy").Frame.Owns
local Fram = game.Players.LocalPlayer.PlayerGui:WaitForChild("main").Frame
part.MouseClick:Connect(function()
gui.Visible = true
end)
if part.MouseClick and Owns.Value == true
then
gui.Visible = false
Fram.Visible = true
end
There could be a lot of problems with your code and even in your gui’s. one thing I would like to point out real quick is to make it easier to define your things. You could easily set it up like this:
local playergui = game.Players.LocalPlayer.PlayerGui
local gui = playergui:WaitForChild("buy")
local guiFrame = gui.Frame
local Owns = gui.Frame.Owns
local Fram = playergui:WaitForChild("main").Frame
Now to actually get to one problem, make sure your owns value is true. you can check it by printing the value before checking the value.
local playergui = game.Players.LocalPlayer.PlayerGui
local gui = playergui:WaitForChild("buy")
local guiFrame = gui.Frame
local Owns = gui.Frame.Owns
local Fram = playergui:WaitForChild("main").Frame
local part = game.Workspace.click.ClickDetector
part.MouseClick:Connect(function()
gui.Visible = true
end)
if part.MouseClick and Owns.Value == true
then
print("Working")
gui.Visible = false
Fram.Visible = true
end
local playergui = game.Players.LocalPlayer.PlayerGui
local gui = playergui:WaitForChild("buy")
local guiFrame = gui.Frame
local Owns = gui.Frame.Owns
local Fram = playergui:WaitForChild("main").Frame
part.MouseClick:Connect(function()
gui.Visible = true
if Owns.Value == true then
Farm.Visible = true
gui.Visible = false
end
end)
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local EP = player:FindFirstChild("leaderstats1")
local points = EP:FindFirstChild("ElitePoints")
local Owns = script.Parent.Parent.Owns
if points ~= nil then
points.Value = points.Value + 90
Owns.Value = true
end
end)
This is your if statement then, you need to check to see if the owns value is true repeatedly. You only check it once and right when the player joins in the game.
local playergui = game.Players.LocalPlayer.PlayerGui
local gui = playergui:WaitForChild("buy")
local guiFrame = gui.Frame
local Owns = gui.Frame.Owns
local Fram = playergui:WaitForChild("main").Frame
local part = workspace.click.ClickDetectorart.MouseClick:Connect(function()
if Owns.Value == false then
guiFrame.Visible = true
else
Fram.Visible = true
guiFrame.Visible = false
end
end)
I believe this will have the effect you are looking for.
local playergui = game.Players.LocalPlayer.PlayerGui
local gui = playergui:WaitForChild("buy")
local guiFrame = gui.Frame
local Owns = gui.Frame.Owns
local Fram = playergui:WaitForChild("main").Frame
part.MouseClick:Connect(function()
gui.Visible = true
if Owns.Value == true then
Farm.Visible = true
gui.Visible = false
end
end)
Ok so first it should be in a server script. The Click detector has a parameter for a player object value.
local part = game.Workspace.click.ClickDetector
part.MouseClick:Connect(function(Player)
local playergui = Player.PlayerGui
local gui = playergui:WaitForChild("buy")
local guiFrame = gui.Frame
local Owns = gui.Frame.Owns
local Fram = playergui:WaitForChild("main").Frame
gui.Visible = true
-- Bla bla bla
end)
I’m pretty sure that would fix the problem but then again, I did skim this post.