What is my goal?
I want to get the childrens of a ViewportFrame and find the one children who have a child Value named “Level”.
the problem is that the script doesn’t want work
Solutions I tried?
look on the dev forum and didn’t find anything
tried to check back on my script still didn’t find any error
is someone here who can help me?
“LocalScript”
game.Players.PlayerAdded:Connect(function(player)
local playerLevel = player.leaderstats:WaitForChild("Level")
local shop = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Shop")
local primaryShopButton = shop:WaitForChild("PrimaryShopButton")
local frameLevel = script.Parent:WaitForChild("FrameLevel")
primaryShopButton.MouseButton1Click:Connect(function()
wait(.1)
for _, v in pairs(script.Parent:GetChildren()) do
if v:FindFirstChild("Level") then
elseif v.Value >= playerLevel.Value then
frameLevel.Visible = false
else
frameLevel.Visible = true
end
end
end)
end)
I get into a new problem that the bouton doesn’t want to work.
do you have any idea?
How can I replace all those Parent.Parent.Parent.Parent.Parent… to be sure that the LocalScript can find the Bouton.
“it doesn’t print Click”
still don’t print()
but I change the part of my script with Parent.Parent.Parent.Parent.Parent to game.StarterGui:WaitForChild(“Shop”), like that I am more sure that the LocalScript is finding the bouton
The reason nothing works is because of using PlayerAdded inside of a LocalScript.
Just put the script inside of the StarterPlayer.StarterPlayerScripts, remove the PlayerAdded function and make a new variable called “player” which is game.Players.LocalPlayer
You’ll need to change some variables after that, so make sure that you remove every script.Parent and change them to: player:WaitForChild("PlayerGui"):WaitForChild("Shop").PrimaryShopButton (refer from PlayerGui instead from the script)