My game runs off tools which use 2 different local scripts (keybind manager and the actual main local script which handles vfx,sound,animation) and a server script which handles the damage,stun etc.
Tools are cloned into the player’s backpack.
The issue im facing currently is that only players with the tools being used by me can see the vfx. if players do not own the same tool as me and I use a move, they see the animation, bodyvelocity but not the vfx. If the have the tool they see vfx,animation and bodyvelocity.
Local Script #1 (Keybind Manager)
local tool = script.Parent
local remote = game.ReplicatedStorage["Client Replicator"]
local damagehandler = game.ReplicatedStorage["Damage Handler"]
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
debounce = false
local toolname = script.Parent.Name
tool.Activated:Connect(function()
print("Activated")
if debounce == false then
local isStunned = char:GetAttribute("Stunned")
if isStunned then
return -- If already stunned, do nothing
else
remote:FireServer("Chidori")
debounce = true
for i = 6, 0, -1 do
tool.Name = i.."s"
print(i)
wait(1)
end
debounce = false
tool.Name = toolname
end
end
if debounce == true then
print("debounce")
return
end
end)
Local Script #2 (Main client handler)
local remote = game.ReplicatedStorage["Client Replicator"]
remote.OnClientEvent:Connect(function(player, move)
local char = player.Character
local hum = char.Humanoid
if move ~= "Chidori" then
return
end
local anim = Instance.new("Animation", hum)
local animId = "rbxassetid://81728699129447"
anim.AnimationId = animId
hum:LoadAnimation(anim):Play()
char:SetAttribute("Stunned", true)
local sound = Instance.new("Sound", char.Head)
sound.SoundId = "rbxassetid://4669616835"
sound.Volume = 0.4
sound:Play()
task.wait(0.5)
sound.Volume = 1
local Chargeupvfx = game.ReplicatedStorage.VFX.NinjaAssets.ChidoriCharge:Clone()
Chargeupvfx.Parent = game.Workspace
Chargeupvfx.CFrame = char:FindFirstChild("Right Arm").CFrame * CFrame.new(0,-1.5,0)
local weld = Instance.new("WeldConstraint")
weld.Part0 = Chargeupvfx
weld.Part1 = char:FindFirstChild("Right Arm")
weld.Parent = Chargeupvfx
wait()
--Chargeupvfx.Attachment.Circle:Emit(1)
Chargeupvfx.Attachment.Circles:Emit(15)
Chargeupvfx.Attachment.L2:Emit(5)
Chargeupvfx.Attachment.Spark:Emit(15)
Chargeupvfx.Attachment.Star:Emit(2)
Chargeupvfx.Attachment.Swirl:Emit(2)
wait(0.5)
local bv = Instance.new("BodyVelocity", char.PrimaryPart)
local Chidori = game.ReplicatedStorage.VFX.NinjaAssets.Chidori:Clone()
Chidori.Parent = game.Workspace
Chidori.CFrame = char:FindFirstChild("Right Arm").CFrame * CFrame.new(0,-1.5,0)
local weld2 = Instance.new("WeldConstraint")
weld2.Part0 = Chidori
weld2.Part1 = char:FindFirstChild("Right Arm")
weld2.Parent = Chidori
local damagehandler = game.ReplicatedStorage["Damage Handler"]
local debounce = false
local damage = 15
local ability = "Ninja Star"
Chidori.Touched:Connect(function(Hit)
if Hit then
if Hit.Parent then
print("Found")
if Hit.Parent:FindFirstChild("Humanoid") then
if Hit.Parent ~= char then
if debounce == true then
return
end
if debounce == false then
debounce = true
print(Hit.Parent)
local enemyhum = Hit.Parent:FindFirstChild("Humanoid")
damagehandler:FireServer(enemyhum,damage,2)
wait(1)
debounce = false
end
end
end
end
end
end)
delay(1, function()
weld:Destroy()
weld2:Destroy()
Chidori:Destroy()
Chargeupvfx:Destroy()
bv:Destroy()
sound:Destroy()
char:SetAttribute("Stunned", false)
end)
while task.wait() do
bv.MaxForce = Vector3.new(99999,99999,99999)
bv.Velocity = (char.PrimaryPart.CFrame.lookVector * 100) + (char.PrimaryPart.CFrame.UpVector * 10)
bv.Name = "Velocity"
game.Debris:AddItem(bv,1)
end
end)
Server Script #1
local remote = game.ReplicatedStorage["Client Replicator"]
remote.OnServerEvent:Connect(function(player, move)
remote:FireAllClients(player, move)
end)