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)```
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?