Hi!, I’m currently working on a game and decided to make a proximity prompt paper note as a function at the cash register counter I’m building.
I watched a few tutorials on the topic and none have worked and I’m looking for any advice/help on the situation on how to make this stupid thing actually work.
I’m not a very good scripter by any standpoint but I do know some scripting basics.
local ProximityPart = script.Parent.PaperNote
-- local ProximityService = game:GetService("ProximityPromptService") (remove the comments if you actually need this)
ProximityPart.ProximityPrompt.Triggered:Connect(function(player)
local Gui = script.Parent:WaitForChild("Note")
Gui.Enabled = not Gui.Enabled
end)
local Gui = script.Parent:WaitForChild("Note")
Gui.Frame.TextButton.Activated:Connect(function()
Gui.Enabled = not Gui.Enabled
end)
I edited the script and it’s still not working, I don’t know if I have it put in the wrong place or whatever, but any time I click or even press E on the proximity prompt it does nothing. Am I doing anything wrong?
Make a local script inside StarterPlayerScripts, write this script inside. LocalScripts dont work in workspace btw!
local plr = game.Players.LocalPlayer
local prompt = workspace:WaitForChild("UrPart").ProximityPrompt
prompt.Trigged:Connect(function()
plr.PlayerGui.Note.Enabled = true --put the note gui in starterGui for this to work
wait(5)
plr.PlayerGui.Note.Enabled = false
end)
How can you need remote events in any way? They cost decent amounts of memory and are TRULY useless in this case, the script I wrote for him should work just fine
The reason this isn’t working is because you’re setting the visibility from the server and client and when you set it from the client it doesn’t replicate to the server so the server will continue to believe the Gui is visible even when it has been set to invisible locally.
ProximityPrompts only functions on instances such as Part in the 3D world, not on User Interface objects such as ScreenGui, which is what you’ve done.
Create a new Partin the workspace, just like you created the ScreenGui. Create a ProximityPrompt in that Part. Name the Part “PromptPart”.
That Part is now your prompt. Place it where you want players to interact with it.
Now, create a LocalScriptin the “Note” ScreenGui. The name is optional. Use this:
-- LocalScript in StarterGui - Note
local note = script.Parent
local button = note.Frame.TextButton -- path your button
local prompt = workspace.PromptPart.ProximityPrompt
-- when prompt triggered //
prompt.Triggered:Connect(function()
note.Enabled = true
end)
-- when button clicked //
button.Activated:Connect(function()
note.Enabled = false
end)