Reposition script making my Proximityprompt not appear?

  1. What do you want to achieve? I am trying to make a random position script, which puts the gun at a random position once the round starts. Once the gun is in position the proximity prompt should appear and the gun should turn invisible and disable the prompt until the next round is started.

  2. What is the issue? The guns proximity prompt works before the position part of the script activates, after the gun is put into one of the 6 positions, the proximity prompt does NOT appear.

  3. What solutions have you tried so far? I have asked for help in a discord server and they told me try to use a table and It did not work. I have also tried instead of disabling the prompt, deleting it and Instance.New(‘ProximityPrompt’, script.parent) once the round starts but none of these solutions have worked (see video for visual)

local realtool = game.Lighting.UZI
local ProximityPrompt = script.Parent.ProximityPrompt
local prompt = script.Parent.ProximityPrompt
local anim = script.Parent.Animation
local positions = game.Workspace.Positions
local spawn = game.ReplicatedStorage.SpawnItems
--this is the positioning part of the script
local uzi = script.Parent
local pos1 = positions.uzi1
local pos2 = positions.uzi2
local pos3 = positions.uzi3
local pos4 = positions.uzi4
local pos5 = positions.uzi5
local pos6 = positions.uzi6
local ori1 = positions.uzi1.Orientation
local ori2 = positions.uzi2.Orientation
local ori3 = positions.uzi3.Orientation
local ori4 = positions.uzi4.Orientation
local ori5 = positions.uzi5.Orientation
local ori6 = positions.uzi6.Orientation
local num = math.random(1,6)
function setpos1()
	uzi.Position = pos1.Position
	uzi.Orientation = ori1
end
function setpos2()
	uzi.Position = pos2.Position
	uzi.Orientation = ori2
end
function setpos3()
	uzi.Position = pos3.Position
	uzi.Orientation = ori3
end
function setpos4()
	uzi.Position = pos4.Position
	uzi.Orientation = ori4
end
function setpos5()
	uzi.Position = pos5.Position
	uzi.Orientation = ori5
end
function setpos6()
	uzi.Position = pos6.Position
	uzi.Orientation = ori6
end
spawn.Event:Connect(function()
	prompt.Enabled = true
	script.Parent.Transparency = 0
	if num == 1 then
		setpos1()

	elseif num == 2 then
		setpos2()

	elseif num == 3 then
		setpos3()

	elseif num == 4 then
		setpos4()

	elseif num == 5 then
		setpos5()

	elseif num == 6 then
		setpos6()
	end
end)
--this is the prompt part of the script
ProximityPrompt.Triggered:Connect(function(Player)
	local hum = Player.Character:WaitForChild("Humanoid")
	local loadAnim = hum.Animator:LoadAnimation(anim)
		loadAnim:play()
	prompt.Enabled = false
	wait(.4)
	realtool:Clone().Parent = Player:WaitForChild("Backpack")
	script.Parent.Transparency = 1
end)


Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

2 Likes

Try to delete one of these and fix the script.

local ProximityPrompt = script.Parent.ProximityPrompt
local prompt = script.Parent.ProximityPrompt

Or it can be the position didn’t update, you should use CFrame instead.

1 Like