Hi all. I’ve run into an issue when using proximity prompts. It’s worth noting that my scripting knowledge is extremely limited, but I’m just messing around to see what I can achieve.
This is my current setup:
This is the LocalScript:
local ProximityPrompt = script.Parent
local plr = game.Players.LocalPlayer
local function onPromptTriggered(ProximityPrompt, plr)
game.StarterGui.ScreenGui.TextBox.Text = 'changed'
end
PPS.PromptTriggered:Connect(onPromptTriggered)
I’m not looking for someone to just write the fixed script and leave it at that - I want to know why it isn’t working. Any help would be greatly appreciated!
local ProximityPrompt = script.Parent
local plr = game.Plaeyrs.LocalPlayer
local function onPromptTriggered(ProximityPrompt, plr)
plr.PlayerGui.ScreenGui.TextBox.Text = 'changed'
end
PPS.PromptTriggered:Connect(onPromptTriggered)
local plr = game.Plaeyrs.LocalPlayer – You’ve mispelt “Players” here, which will prevent the script from running.
Anyways, the main issue here is you’re changing the StarterGui here, rather than the PlayerGui. You can think of StarterGui like a container, whenever a player joins, the StarterGui gets cloned to the PlayerGui. You can reference the Players PlayerGui by simply doing:
plr.PlayerGui.ScreenGui.TextBox.Text
Although, it may be even easier depending on where your script is located to just refrence the TextBox. (ie. script.Parent.TextBox.Text). Try to change the location of your script to right under the TextBox, and simply do script.Parent.TextBox.Text.
I’m not looking for someone to just write the fixed script and leave it at that - I want to know why it isn’t working. Any help would be greatly appreciated!
Thanks for the quick help everyone. Was able to change the LocalScript to a Script, and then do the PlayerGui thing. Again, really appreciative for all the help.
Yes, that’s why I recommended the change to right under the TextBox in my post, that way it’s much simpler to reference the TextBox. Either way, server script works fine for this as well.