In a gun I am making I have it switch modes from Stun, Poison and Damaging. The modes swap perfectly but for some reason once swapped the Server Script won't process the mode causing it to not do what its supposed to. I'm not too sure why it does this maybe the script needs to keep reading it at all times the mode but I'm not too sure how to do it, If this isn't the problem and I'm being dumb please help me. (Modes changed with Local script, however this part of the script below is from the server script that once the mode is changed it should to this.)

local Stun = script.Parent.Modes.Stun:Clone()
local Poison = script.Parent.Modes.Poison:Clone()
local CurrentMode = script.Parent.Modes.Mode.Value
game.Debris:AddItem(Attachment,3)
if part.Name == "Head" or part.Parent:IsA("Accessory") then
            if CurrentMode == "Damaging" then
        humanoid:TakeDamage(damage*FireMultiplier)
    elseif CurrentMode == "Stun" then
            humanoid:TakeDamage(damage*HeadMultiplier)
            Stun.Disabled = false
            Stun.Parent = humanoid.Parent
    elseif CurrentMode == "Poison" then
        humanoid:TakeDamage(damage*HeadMultiplier)
        Poison.Disabled = false
        Poison.Parent = humanoid.Parent
    end

3 comments

0

CurrentMode:GetPropertyChangedSignal("Value"):Connect(function() [[ If statements ]]

0

Remove the ‘Value’ prefix from line 3

0

Doesn't seem to work in fact it messes with the whole script after.