Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When there is 2 or more players, one player can transform, but the other cannot?

Asked by
Jirozu 71
6 years ago

PROBLEM My script has a problem where if there is 2 or more players in the game, if one player transforms, the other cannot and gets somewhat "stuck" and cannot transform without resetting, I am confused and do not know how to fix this.

LOCAL SCRIPT

-- player
local Player = game.Players.LocalPlayer
local Character = Player.Character
repeat wait() until Player or Character ~= nil

-- input
local UIS = game:GetService("UserInputService")

-- variables
local CanChange = true
local InTransformation = false
local RemoteEvents = game.ReplicatedStorage.RemoteEvents

--{{ tranformation }}--
UIS.InputBegan:Connect(function(input, gpe)
    if input.KeyCode ~= Enum.KeyCode.Z then return end;
    if gpe then return end;
    if CanChange == true then
        CanChange = false
        if InTransformation == true then return end;
        if InTransformation == false then
            print("DEBUG MSG: Super Saiyan Transformation")

            -- remotevent
            RemoteEvents.Transformations.TransformSSJEvent:FireServer()

            InTransformation = true
        end
        print("DEBUG MSG: Script Got to wait")
        wait(5)
        CanChange = true
        print("DEBUG MSG: Script Finished Wait")
    end
end)


--{{ deformation }}--
UIS.InputBegan:Connect(function(input, gpe)
    if input.KeyCode ~= Enum.KeyCode.X then return end;
    if gpe then return end;
    if CanChange == true then
        CanChange = false
        if InTransformation == false then return end;
        if InTransformation == true then
            print("DEBUG MSG: Reverted back to base")

            --remoteevent
            RemoteEvents.Transformations.DeformSSJEvent:FireServer()

            InTransformation = false
        end
        print("DEBUG MSG: Script got to wait")
        wait(5)
        CanChange = true
        print("DEBUG MSG: Script finished wait")
    end
end)

SCRIPT

--multiplyers
local GreatApeMultiplier = 3
local SSJMultiplier = 5
local SSJ2Multiplier = 10
local SSJ3Multiplier = 25
local SSJGMultiplier = "?"
local SSJBMultiplier = "?"

-- variables
local RemoteEvents = game.ReplicatedStorage.RemoteEvents
local inSSJ = false

--{{ transformation }}--
RemoteEvents.Transformations.TransformSSJEvent.OnServerEvent:Connect(function(Player)
    if inSSJ == false then
        print("DEBUG MSG: Server Got Super Saiyan")

        --{{ animations }}--

        -- color tween
        local TweenService = game:GetService("TweenService")
        local Hair = Player.Character:WaitForChild("BaseHair")
        local Info = TweenInfo.new(2, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, false, 0)
        local Goals = {Color = Color3.new(1 , 1, 1)}
        local HairTween = TweenService:Create(Hair, Info, Goals)

        -- dust animations
        local DustRingPowerIn = game.ReplicatedStorage.Effects.DustRingPowerIn:Clone()
        DustRingPowerIn.Parent = Player.Character
        DustRingPowerIn.Size = Vector3.new(10, 0.05, 10)
        DustRingPowerIn.CFrame = Player.Character["HumanoidRootPart"].CFrame * CFrame.new(0, -1.5, 0) * CFrame.Angles(0, math.random(-90, 90), 0)

        -- play tween
        HairTween:Play()        
        wait(1.5)

        -- hair change
        Player.Character:FindFirstChild("BaseHair").Transparency = 1
        Player.Character:FindFirstChild("SSJHair").Transparency = 0

        -- explosion
        for i = 0, 6 do
            local Ki = game.ReplicatedStorage.Effects.KiExplosionPart:Clone()
            Ki.Parent = Player.Character
            Ki.Size = Vector3.new(1, 1.525, 1)
            Ki.CFrame = Player.Character["HumanoidRootPart"].CFrame * CFrame.Angles(math.random(-90, 90), math.random(-90, 90), math.random(-90, 90))
        end
        for i = 0, 5 do
            local DustRingPowerOut = game.ReplicatedStorage.Effects.DustRingPowerOut:Clone()
            DustRingPowerOut.Parent = Player.Character
            DustRingPowerOut.Size = Vector3.new(10, 0.05, 10)
            DustRingPowerOut.CFrame = Player.Character["HumanoidRootPart"].CFrame * CFrame.new(0, -1.5, 0) * CFrame.Angles(0, math.random(-90, 90), 0)
            wait(0.08)
        end

        -- power boosts


        inSSJ = true
    end
end)

--{{ deformation }}--
RemoteEvents.Transformations.DeformSSJEvent.OnServerEvent:Connect(function(Player)
    if inSSJ == true then
        print("DEBUG MSG: Server Got Base")

        --{{ animations }}--

        -- color tween
        local TweenService = game:GetService("TweenService")
        local Hair = Player.Character:WaitForChild("BaseHair")
        local Info = TweenInfo.new(2, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, false, 0)
        local Goals = {Color = Color3.new(0 , 0, 0)}
        local HairTween = TweenService:Create(Hair, Info, Goals)

        -- hair change
        Player.Character:FindFirstChild("BaseHair").Transparency = 0
        Player.Character:FindFirstChild("SSJHair").Transparency = 1

        HairTween:Play()
        wait(1.5)

        -- remove power boosts

        inSSJ = false
    end
end)

FINAL THOUGHTS Please excuse me for the long script.

Answer this question