So Im trying to disable a proximity prompt for a certain player, but then i came across the great attempt index nil error. I am confused by why this occurs as it was cloned by the server itself
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EnablePrompt = ReplicatedStorage:WaitForChild("EnablePrompt")
local Prox = script:WaitForChild("Arrest") -- Keep this outside of your function
-- Inside of your function
local HumanoidRootPart = Character:FindFirstChild("Humanoid")
if HumanoidRootPart then
local prox = Prox:Clone()
prox.Parent = character.HumanoidRootPart
prox.ActionText = 'Arrest'
prox.ObjectText = player.Name
EnablePrompt:FireClient(player, prox, false)
end
--Clientside
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EnablePrompt = ReplicatedStorage:WaitForChild("EnablePrompt")
EnablePrompt.OnClientEvent:Connect(function(prompt, state)
print(prompt, state) -- nil false
if prompt then
prompt.Enabled = state
end
end)