Anyone know why this proximity prompt script isn't working?

I’m making a script in which when a proximity prompt is activated (It’s a local script), and when the remote event is activated, a rope is created that has attachments connected to the cart and the player. The script prints nothing though, and I’m not sure what to do. There are no errors either, so I’m stuck right now.

local pp = script.Parent

local RS = game:GetService("ReplicatedStorage")
local AttatchRope = RS:WaitForChild("Remotes"):WaitForChild("AttatchRopeToTransport")
local DetatchRope = RS:WaitForChild("Remotes"):WaitForChild("DetatchRopeToTransport")

local clicked = 0

local cooldown = false

pp.Triggered:Connect(function(player)
	print(pp.Parent:GetAttribute("Ownership"))
	print(player.Name == pp.Parent:GetAttribute("Ownership"))
	if player.Name == pp.Parent:GetAttribute("Ownership") and clicked == 0 then
		if not cooldown then cooldown = true elseif cooldown then return end
		local transportVehicle = pp.Parent.Parent
		clicked += 1
		AttatchRope:FireServer(player, transportVehicle)
		
		task.wait(.558)
		
		cooldown = false
	elseif player.Name == pp.Parent:GetAttribute("Ownership") and clicked == 1 then
		if not cooldown then cooldown = true elseif cooldown then return end
		local transport = pp.Parent.Parent
		clicked -= 1
		DetatchRope:FireServer(player, transport)
		
		task.wait(.558)
		
		cooldown = false
	end
end)
local RS = game:GetService("ReplicatedStorage")
local AttatchRope = RS:WaitForChild("Remotes"):WaitForChild("AttatchRopeToTransport")
local DetatchRope = RS:WaitForChild("Remotes"):WaitForChild("DetatchRopeToTransport")

AttatchRope.OnServerEvent:Connect(function(player, transporter)
	local playerChar = player.Character
	local RightArm = playerChar:FindFirstChild("Right Arm")
	
	local Rope = Instance.new("RopeConstraint", RightArm)
	Rope.Name = "Rope"
	Rope.Attachment0 = Instance.new("Attachment", RightArm)
	Rope.Attachment0.Name = "RopeConstraintAttatchment"
	Rope.Attachment1 = Instance.new("Attachment", transporter:WaitForChild("RopePart"))
	Rope.Attachment1.Name = "RopeConstraintAttatchment"
end)

DetatchRope.OnServerEvent:Connect(function(player, transporter)
	local playerChar = player.Character
	local RightArm = playerChar:FindFirstChild("Right Arm")

	local Rope = RightArm:WaitForChild("Rope")
	Rope.Attatchment0:Destroy()
	Rope.Attatchment1:Destroy()
	Rope:Destroy()
end)

Local scripts cannot be used with ProximityPrompts. You must use a serverscript which then fires an event to a localscript that’s either in StarterPlayerScripts or any other valid localscript container.

Can I also use a remote function for this?

I’m not too familiar with those, but I suppose you could try.

ProximityPrompts are only used in ServerSide Scripts. You can use RemoteEvents, RemoteFunctions, etc.

1 Like

You’re printing the wrong values. It’s not the player.Name that you want. The player is the first argument. Instead of this:
print(pp.Parent:GetAttribute(“Ownership”))
print(player.Name == pp.Parent:GetAttribute(“Ownership”))

Try this:
print(pp.Parent:GetAttribute(“Ownership”))
print(player.Name == pp.Parent:GetAttribute(“Ownership”))