I’m still a bit new to module scripts and how they work globably and locally. I’m working on a vfx function and I put all of my functions inside of a module script to keep things organized. The problem is the vfx functions and welds from the module script are being replicated to the other players who didn’t even use the moves. It even welds to other player’s HumanoidRootpart, making us stick together. How can I change my module script functions to only work on the player who used the move instead of all players?
Video of me explaining: Module script problem - YouTube
MODULE SCRIPT:
local HakiType = {}
function HakiType.ConquersHakiRed(Player, Character)
local TweenService = game:GetService("TweenService")
local Head = Character["Head"]
local HumanoidRootPart = Character['HumanoidRootPart']
local ConquerEffects = game:GetService("ReplicatedStorage").VFX.ConquersHaki
local CircleRing = ConquerEffects.Circle:Clone()
local Wave3 = ConquerEffects.Wave3:Clone()
local WindVFX = ConquerEffects["Wind[C.Haki]"]:Clone()
local Wind2VFX = ConquerEffects["Wind2[C.Haki]"]:Clone()
local LidVFX = ConquerEffects.FireBall:Clone()
local Lid = ConquerEffects.Part:Clone()
CircleRing.Parent = HumanoidRootPart
Wave3.Parent = HumanoidRootPart
WindVFX.Parent = HumanoidRootPart
Wind2VFX.Parent = HumanoidRootPart
Lid.Parent = HumanoidRootPart
LidVFX.Parent = HumanoidRootPart
print("Other parts welded")
local W1 = Instance.new('WeldConstraint')
W1.Part0 = HumanoidRootPart
W1.Part1 = Lid
W1.Name = "Lid [Conquers Haki Red]"
W1.Part1:PivotTo(HumanoidRootPart.CFrame)
W1.Parent = HumanoidRootPart
local W2 = Instance.new('WeldConstraint')
W2.Part0 = Lid
W2.Part1 = LidVFX
W2.Name = "LidVFX [Conquers Haki Red]"
W2.Part1:PivotTo(Lid.CFrame)
W2.Parent = Lid
local W = Instance.new('WeldConstraint')
W.Part0 = HumanoidRootPart
W.Part1 = CircleRing
W.Name = "CircleRing [Conquers Haki Red]"
W.Part1:PivotTo(HumanoidRootPart.CFrame)
W.Parent = HumanoidRootPart
local T = Instance.new('WeldConstraint')
T.Part0 = HumanoidRootPart
T.Part1 = Wave3
T.Name = "Wave3 [Conquers Haki Red]"
T.Part1:PivotTo(HumanoidRootPart.CFrame)
T.Parent = HumanoidRootPart
local E = Instance.new('WeldConstraint')
E.Part0 = HumanoidRootPart
E.Part1 = WindVFX
E.Name = "WindVFX [Conquers Haki Red]"
E.Part1:PivotTo(HumanoidRootPart.CFrame)
E.Parent = HumanoidRootPart
local M = Instance.new('WeldConstraint')
M.Part0 = HumanoidRootPart
M.Part1 = Wind2VFX
M.Name = "Wind2VFX [Conquers Haki Red]"
M.Part1:PivotTo(HumanoidRootPart.CFrame * CFrame.new(0,15,0))
M.Parent = HumanoidRootPart
--Tweening
local info = TweenInfo.new(
2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local info2 = TweenInfo.new(
3,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local endinfo = TweenInfo.new(
3,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local InfoType = TweenInfo.new( 2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
local Goal = {Transparency = 0;
Orientation = Vector3.new(CircleRing.Position) + Vector3.new(0, 3000, 0 );
Size = Vector3.new(215.596, 1, 226.428)
}
local Goal2 = {Transparency = 0;
Orientation = Vector3.new(Wave3.Position) + Vector3.new(0,-3000, 0);
Size = Vector3.new(205.322, 0.584, 234.662)
}
local endGOAL = { Transparency = 1;
}
local Goal3Lid = {Transparency = 0.8;
Orientation = Vector3.new(Lid.Position) + Vector3.new(0, -2000, 0);
Size = Vector3.new(197.563, 197.23, 208.115)
}
local Goal4LidVFX = {Transparency = 0.8;
Orientation = Vector3.new(Lid.Position) + Vector3.new(0,2000, 0);
Size = Vector3.new(176.716, 176.418, 186.155);
Color = Color3.new(1, 1, 1)}
local Created = TweenService:Create(CircleRing, info, Goal)
local Created2 = TweenService:Create(Wave3, info2, Goal2)
local LastTween = TweenService:Create(Wave3, endinfo, endGOAL)
local LastTween2 = TweenService:Create(CircleRing, endinfo, endGOAL)
local LastTween3 = TweenService:Create(Lid, InfoType, Goal3Lid)
local LastTween4 = TweenService:Create(LidVFX, InfoType, Goal4LidVFX)
local LastTween5 = TweenService:Create(Lid, endinfo,endGOAL)
local LastTween6 = TweenService:Create(LidVFX, endinfo,endGOAL)
LastTween3:Play()
LastTween4:Play()
Created:Play()
Created2:Play()
task.wait(1)
LastTween:Play()
LastTween2:Play()
LastTween5:Play()
LastTween6:Play()
task.wait(3)
--[[Character:FindFirstChild("Circle"):Destroy()
Character:FindFirstChild("Wave3"):Destroy()
Character:FindFirstChild("Wind[C.Haki]"):Destroy()
Character:FindFirstChild("Wind2[C.Haki]"):Destroy()
Character:FindFirstChild("Part"):Destroy()
Character:FindFirstChild("FireBall"):Destroy()]]
print("All items have been destroyed.")
end
return HakiType
SERVER SCRIPT:
local ConquerRemote = game:GetService("ReplicatedStorage"):WaitForChild("ConquerClash")
local Gui = game:GetService("StarterGui").ConquerGui
local ConquersHakiModule = require(script.ConquersModule)
local Sound = game.Workspace.Laugh
local ConquerEffects = game:GetService("ReplicatedStorage").VFX.ConquersHaki
local BubbleRangeVFX = ConquerEffects["BubbleRange[C.Haki]"]:Clone()
local ConquersHaki = ConquerEffects["Conqurers Haki"]:Clone()
local Track
ConquerRemote.OnServerEvent:Connect(function(player, Ins)
if Ins == "Haki" then
local Character = player.Character
local HumanoidRootPart = Character.HumanoidRootPart
ConquersHaki.Parent = HumanoidRootPart
BubbleRangeVFX.Parent = HumanoidRootPart
local G = Instance.new('WeldConstraint')
G.Part0 = HumanoidRootPart
G.Part1 = BubbleRangeVFX
G.Name = "BubbleRangeVFX [Conquers Haki Red]"
G.Part1:PivotTo(HumanoidRootPart.CFrame)
G.Parent = HumanoidRootPart
local R = Instance.new('WeldConstraint')
R.Part0 = HumanoidRootPart
R.Part1 = ConquersHaki
R.Name = "ConquersHaki [Conquers Haki Red]"
R.Part1:PivotTo(HumanoidRootPart.CFrame)
R.Parent = HumanoidRootPart
Sound:Play()
ConquersHakiModule.ConquersHakiRed(player, Character)
local Data = {Outcome = "Passout"}
ConquerRemote:FireClient(player, Data)
for i, enemy in game.Workspace:GetDescendants() do
if enemy:IsA("Model") and enemy:FindFirstChild("Humanoid") and enemy.Name ~= player.Name then --Checks
local Enemy = enemy
print(Enemy.Name)
if (Enemy.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude < 60 then
local Anim = Instance.new("Animation", Enemy)
Anim.Name = "PassOut"
Anim.AnimationId = "rbxassetid://11715519098"
-- Enemy.PlayerGui.ConquerGui.Enabled = true
Track = Enemy.Humanoid.Animator:LoadAnimation(Anim)
Track:Play()
Enemy.Humanoid.WalkSpeed = 0
Enemy.Humanoid.JumpHeight = 0
Track:GetMarkerReachedSignal("Freeze"):Connect(function(paramString)
Track:Stop()
Enemy:FindFirstChild("PassOut"):Destroy()
local NewTrack = Instance.new("Animation")
NewTrack.Name = "Passout"
NewTrack.AnimationId = "rbxassetid://11717032938"
NewTrack.Parent = Enemy
local Track2 = Enemy.Humanoid.Animator:LoadAnimation(NewTrack)
Track2:Play()
task.wait(10)
Track2:Stop()
Anim:Destroy()
Enemy.Humanoid.WalkSpeed = 16
Enemy.Humanoid.JumpHeight = 7.2
end)
end
end
end
end
end)
LOCAL SCRIPT:
player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local ConquerRemote = game:GetService("ReplicatedStorage"):WaitForChild("ConquerClash")
local GEAR5ANIM = script:WaitForChild("Conqueranim")
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(
5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
1,
false,
0
)
local Goal = {BackgroundTransparency = 0.1}
UIS.InputBegan:Connect(function(input, GPE)
if GPE then return end
if input.KeyCode == Enum.KeyCode.G then
local Track = Humanoid:LoadAnimation(GEAR5ANIM)
Track:Play()
Humanoid.WalkSpeed = 0
Humanoid.JumpHeight = 0
ConquerRemote:FireServer("Haki")
task.wait(5)
Track:Stop()
Humanoid.WalkSpeed = 16
Humanoid.JumpHeight = 7.2
end
ConquerRemote.OnClientEvent:Connect(function(Data)
local ConquerGui = game:GetService("StarterGui"):WaitForChild("ConquerGui")
local RedFrame = ConquerGui:WaitForChild("RedFrame")
local BlackFrame = ConquerGui:WaitForChild("BlackFrame")
local TweenValue = TweenService:Create(BlackFrame, Info, Goal)
if Data.Outcome == "Passout" then
ConquerGui.Enabled = true
TweenValue:Play()
end
end)
end)
end)