What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I asked in a couple developer servers. I just need guidance. Trying to gain experience through the devforum as well. How can I create a proximity prompt system like the one I linked? The way it’s not 2d like a simple ScreenGui, and is dynamic and has a line from the player to it.
I am new to scripting, but not new to studio, been messing around in it for about 3 1/2 years now, but am just now starting to dip into scripting and modeling. Help and/or guidance would be appreciated it.
Probably check whether the the distance between the player and the door is like maybe 5 studs (or whatever) away from the door. Then, just like draw the line from the Player’s HumanoidRootPart to the door.
You could do something like this (script in the door):
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
while task.wait(1) do
if (script.Parent.Position - Character:WaitForChild(“HumanoidRootPart”).Position).Magnitude <= 5 then -- or whatever amount of studs
-- Draw the line and add your custom proximity prompt
game:GetService(“UserInputService”).InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
-- We’re using the “InputBegan” event in here because since it’s in here, they can only activate the proximity prompt in this function (if they press e and they aren’t close to a door it won’t do anything)
-- Your code
end
end)
end
end
end)
end)
Alright, it is 7:47 PM for me. I appreciate the help very much and I hope I can get this work. I’m very happy to have just been accepted to the forum. I’m hoping this help me learn more.
You could raycast from the HumanoidRootPart’s position to the door’s center point (then set a cylinder/ part to the raycast’s “position” to emulate a line). And you probably would need a surface / billboard gui.
i fixed the errors, and added so that when the players position is within the 5 studs you put it makes it visible, but now it doesnt work and outputs
Position is not a valid member of Workspace.Door
local promptFrame = script.Parent.BillboardGui.Frame
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
while task.wait(1) do
if (script.Parent.Position - Character:WaitForChild("HumanoidRootPart").Position).Magnitude <= 5 then -- or whatever amount of studs
promptFrame.Visible = true
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
end
end)
end
end
end)
end)
No problem, it’s a model. I apologize, I am new to scripting. Maybe I should try and learn more before trying this. But I thought I was good enough to try and get experience making something for once.
Oh and by the way, you have to define “a” after the CharacterAdded event. If you don’t define it after, it doesn’t work. I won’t explain it but there’s a lot of good tutorials and explanations on that you could probably find.
local promptFrame = script.Parent.BillboardGui.Frame
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
while task.wait(1) do
if (script.Parent.Target - Character:WaitForChild("HumanoidRootPart").Position).Magnitude <= 5 then -- or whatever amount of studs
promptFrame.Visible = true
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
end
end)
end
end
end)
end)
local promptFrame = script.Parent.BillboardGui.Frame
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
while task.wait(1) do
if (script.Parent.Target.Position - Character:WaitForChild("HumanoidRootPart").Position).Magnitude <= 5 then
promptFrame.Visible = true
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
end
end)
end
end
end)
end)
Hello, sorry for my absence. I noticed that it doesn’t work at first, but after I press E it is visible, but the magnitude has no play in the outcome. I am unsure why. I am literally stuck.
local Raycast = workspace:Raycast(Character.HumanoidRootPart.Position, Character.HumanoidRootPart.CFrame.LookVector)
if Raycast and Raycast.Instance.Name == script.Parent.Target.Name then
Still dunno if this will solve it (because the code that you already have written should’ve worked), but I guess you could give this a shot.