Turret script not cloning again after the player uses it once

So im using this machine gun script, but when the player dismounts from it and gets back on, they can no longer use it unless they reset.

the problem is the “g” script wont clone again after it is removed from the player. But i do not know how to solve this issue.

here is a portion of the script:

occupier = nil
function powers()
	if script.Parent.Occupant~= nil then
		local a = script.Parent.Occupant
		local b = game.Players:GetPlayerFromCharacter(a.Parent)
		if b~= nil then
			g=script.control:Clone()
			g.Value.Value=script.Parent.Parent.Parent
			g.Parent=b.Character
			g.Disabled=false
			occupier = b
			end
		end
	end
script.Parent.Changed:connect(powers)```
1 Like

Check if Archiveable is enabled in the “g” script properties.

1 Like

It is enabled

its weird because the turret used to work just fine

1 Like

Try adding print statements to see if the script runs the parts

1 Like

I did and it clones the first time the player uses the turret, but once they get up and sit back down, it doesnt clone again.

2 Likes

make sure you’re returning lil bro

2 Likes

could you please give an example?

When is the ‘g’ script removed from the player who dismounts? Is there any cleanup at all? One would expect the if script.Parent.Occupant ~= nil to have an else clause that removes the previous g script and sets occupier back to nil, right?

1 Like

Yes, are you saying that the problem is one occupier is set to nil, it wont go back?