I am trying to make doors that when a prompt shows, a highlight appears… Anyone can tell me why it doesn’t work?
First script
local Handle1CD = script.Parent.Handle1.Attachment.ProximityPrompt
local Handle2CD = script.Parent.Handle2.Attachment.ProximityPrompt
local Remote = script.Parent.EnableHighlight
local RemoteDisabler = script.Parent.DisableHighlight
local Funi = script.Parent.LocalScript
function Highlight(plr)
Remote:FireClient(plr)
end
function HighlightDisabled(plr)
RemoteDisabler:FireClient(plr)
end
Handle1CD.PromptShown:Connect(Highlight)
Handle2CD.PromptShown:Connect(Highlight)
Handle1CD.PromptHidden:Connect(HighlightDisabled)
Handle2CD.PromptHidden:Connect(HighlightDisabled)
Second script (its a local script)
local Remote1 = script.Parent.EnableHighlight
local Remote2 = script.Parent.DisableHighlight
local Highlight = script.Parent.SussyHighlight
Remote1.OnClientEvent:Connect(function(plr)
Highlight.Enabled = true
end)
Remote2.OnClientEvent:Connect(function(plr)
Highlight.Enabled = false
end)
I’ve tried with ClickDetectors but it also didn’t work.
OnClientEvent only works for the server you have specified that the script is inside a local script. Also, since you are using a proximity prompt you don’t need to use a remote event.
Should the highlight be shown to every player? If not, then you can just do that from the client script; you don’t need to use any remote events. The only time where you have to use remote event is anything that must be replicated to the server such buying items etc.
No it won’t show to every player, just the one locally, kinda like the drawers in games such as apeirophobia and doors, the highlights only show to the player
Then all you need is a client/local script, but it would be better to add some attributes or a specific name for that object so there is only a single script that creates a connection for every object that should be highlighted. Example:
for _, object: Instance in ipairs(workspace:GetDescendants()) do
if object.Name:match("Specific Door") then
local proximityPrompt = object:FindFirstChildOfClass("ProximityPrompt")
local highlight = object:FindFirstChildOfClass("Highlight")
proximityPrompt.PromptShown:Connect(function()
highlight.Enabled = true
end)
proximityPrompt.PromptHidden:Connect(function()
highlight.Enabled = false
end)
end
end
for _, object: Instance in ipairs(workspace:GetDescendants()) do
if object.Name:match("DoorFun") then
for i, door in ipairs(object:GetChildren()) do
if door.Name:match("DoorModel") then
local proximityPrompt1 = door.Handle1:FindFirstChildOfClass("Attachment"):FindFirstChildOfClass("ProximityPrompt")
local proximityPrompt2 = door.Handle2:FindFirstChildOfClass("Attachment"):FindFirstChildOfClass("ProximityPrompt")
local highlight = door:FindFirstChildOfClass("Highlight")
proximityPrompt1.PromptShown:Connect(function()
highlight.Enabled = true
end)
proximityPrompt1.PromptHidden:Connect(function()
highlight.Enabled = false
end)
proximityPrompt2.PromptShown:Connect(function()
highlight.Enabled = true
end)
proximityPrompt2.PromptHidden:Connect(function()
highlight.Enabled = false
end)
end
end
end
end
Does it really have to have two proximity prompts? I made something similar, and it does work.
for _, object: Instance in ipairs(workspace:GetChildren()) do
if not (object.Name == "Door") then continue end
local proximityPromt = object:FindFirstChildOfClass("ProximityPrompt")
local highlight = object:FindFirstChildOfClass("Highlight")
proximityPromt.PromptShown:Connect(function()
highlight.Enabled = true
end)
proximityPromt.PromptHidden:Connect(function()
highlight.Enabled = false
end)
end
I mean, i hope it doesn’t and that there’s a way to make the proximity prompt actually work without being put inside an attachment, that would’ve been helpful… Do you know a way on how to make the prompt appear on a model?
I think my studio has a problem: i made another part and placed the script, the highlight and the prompt inside it; the only thing that didn’t work was the highlight… or i’m just unlucky
Edit: i’m going to try in a new place
Edit 2: Also didn’t work, i think my studio is cursed
Was the script in StarterPlayerScripts? Because it worked when i put it there… that was stupid from me… i forgot that local scripts don’t run when they’re parented to a part or anything that isnt in the player in any way