local Prox = script.Parent.ProximityPrompt
Prox.Triggered:Connect(function()
game.StarterGui.CookieGui.MainFrame.Visible = true
end)
so well basically it doesn’t work. lol.
local Prox = script.Parent.ProximityPrompt
Prox.Triggered:Connect(function()
game.StarterGui.CookieGui.MainFrame.Visible = true
end)
so well basically it doesn’t work. lol.
StarterGui changes wont replicate to client. This is because StarterGui’s contents are copied into PlayerGui when the player spawns. For changes to take place, u have to modify PlayerGui.
local Prox = script.Parent.ProximityPrompt
local LocalPlayer = game:GetService("Players").LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
Prox.Triggered:Connect(function()
PlayerGui.CookieGui.MainFrame.Visible = true
end)
oh. Yeah. I keep forgetting about that.
I wrote this but its still does not work.
local Prox = script.Parent.ProximityPrompt
local Player = game:GetService("Players").LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Frame = PlayerGui.CookieGui.MainFrame
Prox.Triggered:Connect(function()
Frame.Visible = true
end)
This is most likely a server script, am I correct? game.Players.LocalPlayer does not work on the server (LocalPlayer). The .Triggered event has a plrWhoTriggered parameter, so you could add that in to your function, like this:
Prox.Triggered:Connect(function(plrWhoTriggered)
plrWhoTriggered:WaitForChild("PlayerGui").CookieGui.MainFrame.Visible = true
end)
its a local script by the way. Sorry about that.
Ah, alright. I’m guessing the script is in the workspace. LocalScripts do not work in workspace unless they are in a player’s character model. You can use the same code from earlier or change the localscript to a server script and use my code. If you continue to use a LocalScript, parent it to one of the following:
Backpack , such as a child of a Tool (Put in StarterPack)character model (Put in StarterCharacterScripts)PlayerGui (Put in StarterGui)PlayerScripts . (Put in StarterPlayerScripts)ReplicatedFirst serviceThen change local Prox = script.Parent.Prox to local Prox = workspace.[PATH TO PROX]
how do I parent it to a playergui? Do I just do
script.Parent = PlayerGui
No. I took this from the LocalScript documentation. StarterGui replicates to the PlayerGui everytime the player spawns. (That’s a hint.)
I’d recommend parenting it to StarterPlayerScripts though. Scripts should go there unless it involves the character because usually those scripts break after respawning.
I parented it to starterplayerscripts but it still does not work.
Did you do this? Of course, you have to replace [PATH TO PROX] with the path to take to get to the prompt. ex: workspace.Model.Part.ProximityPrompt
If something does not work, always check the output. There may be an error such as Attempt to index nil with Triggered
wait. Should I put the local script in the starter gui?
if you put it inside of starter player how do I change its parent to something different if the parent I want to parent it to is not originally there?
Use Instance:WaitForChild(“name of child”), though I’m not too sure why you would need to parent it to something else if it’s already in StarterPlayerScripts? Or is it in StarterPlayer? because that won’t work.