it shows that GuiWinScript isnt a valid member of the model, everything (name wise and position in screenGui works. (all in one script)
local GuiWinScript = game.StarterGui.ScreenGui.YouWin GuiWinScript.BackgroundTransparency = 1 GuiWinScript.TextTransparency = 1 game.Workspace.SandwichBorderModel.IfTouchedStartGUI.Touched:Connect(function() GuiWinScript.TextTransparency = 0 GuiWinScript.BackgroundTransparency = 0.6 end)
You are changing the GUI of the StarterGui which isn't the one the player sees.
Assuming that the script is a local script. You can refer to the correct GUI which is:
local GuiWinScript = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").YouWin
It's because you're changing the GUI that's in the StarterGui, and not in the PlayerGui. Every player has a PlayerGui, when they join the game everything in StarterGui gets moved into their PlayerGui. You have to get the player's PlayerGui and make changes to the GUI's that are in there.
Example: (ServerScript)
local Players = game:GetService("Players") script.Parent.IfTouchedStartGUI.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then -- Checking if the thing that touched the part is a player, this will also detect NPCs. for _, Player in pairs(Players:GetPlayers()) do if Player.Name == hit.Parent.Name then local PlayerGui = Player.PlayerGui local GuiWinScript = PlayerGui.ScreenGui.YouWin GuiWinScript.TextTransparency = 0 GuiWinScript.BackgroundTransparency = 0.6 end end end end)
Another Example: (Local Script) Note, if this is in a local script, your local script has to be located in either, PlayerScripts, PlayerGui, the player's Character, Backpack or ReplicatedFirst. If the local script is inside the part, or in workspace then it won't work.
local Player = game.Players.LocalPlayer local GuiWinScript = Player.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("YouWin") local IfTouchedStartGUI = game.Workspace:WaitForChild("SandwichBorderModel"):WaitForChild("IfTouchedStartGUI") IfTouchedStartGUI.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then GuiWinScript.TextTransparency = 0 GuiWinScript.BackgroundTransparency = 0.6 end end)
--// Variables local Player = game.Players.LocalPlayer local playerGui = Player:WaitForChild("PlayerGui") local GuiWinScript = playerGui:WaitForChild("YouWin") GuiWinScript.BackgroundTransparency = 1 GuiWinScript.TextTransparency = 1 game.Workspace.SandwichBorderModel.IfTouchedStartGUI.Touched:Connect(function() GuiWinScript.TextTransparency = 0 GuiWinScript.BackgroundTransparency = 0.6 end)
Please fix your indentation, also create variables if you want to reference something a lot. StarterGui is not what the player sees, it is immediately cloned to PlayerGui as soon as a player joins. PlayerGui is WHAT the player sees.
Conclusion:
Always create variables for clean code, as well as it makes referencing way easier.
StarterGui is not what the player sees.
If this is on a local script, try doing
local GuiWinScript = game.Players.LocalPlayer.PlayerGui.YouWin
When a player's character is loaded, the contents of StarterGui is copied to PlayerGui which is why the transparency did not change on the player.