Try putting prints to see how far the event is going forward, if something isn’t printing, you know that is not working.
AFAIK when cloning objects, scripts would be the same too, but it must be how you wrote your script.
It doesn’t even enter the event. I heard from a friend that when I use a script to clone parts, and use the variable I use to clone it in order to try and trigger the event, the Touched event won’t be triggered for some reason. I am trying to find an alternative for that.
This is the script. it calls for another that calls it back. It is a client side ran vfx
local ReplicaedStorage = game:GetService('ReplicatedStorage')
local TweenService = game:GetService('TweenService')
local UIS = game:GetService('UserInputService')
local Remote = ReplicaedStorage.MovesRemotes:WaitForChild(script.Name)
local player = game.Players.LocalPlayer
game.Workspace:WaitForChild(player.Name)
local char = player.Character
local IceFolder = Remote.Meshes
local cooldown = 5
local debounce = false
local damage = 25
UIS.InputBegan:Connect(function(key,isTyping)
if isTyping then
return
elseif key.KeyCode == Enum.KeyCode.Z and not debounce and char then
debounce = true
char.PrimaryPart.Anchored = true
Remote:FireServer(player, damage)
wait(cooldown)
char.PrimaryPart.Anchored = false
debounce = false
end
end)
Remote.OnClientEvent:Connect(function(vfx_player, vfx_Damage)
local PlrFolder = game.Workspace.Skills[vfx_player.Name]
local Folder = Instance.new('Folder', PlrFolder)
Folder.Name = script.Name
local val = -4
local sizez = 3
local sizex = 10
local sideval = 1/2
local Shards = {}
local function Ice()
local extra = math.random(-11, 11) / 10
local Shard = IceFolder:WaitForChild("IceSpike1"):Clone()
Shard.Name = "IceShard " .. #Shards + 1
table.insert(Shards, Shard)
local side = math.random(-sideval, sideval)
up = Shard.Size.Y/2
local rotate = math.random(0, 180)
local MRo = math.random(99,100)
if MRo == 99 then
local SRo = math.random(8, 10) / 10
URo = MRo + SRo
else
local SRo = math.random(1, 3) / 10
URo = MRo + SRo
end
Shard.Size = Vector3.new(sizez, sizex, sizez)
Shard.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(side, -up, val + extra)
Shard.Parent = Folder
Shard.CFrame = Shard.CFrame * CFrame.fromEulerAnglesXYZ(URo, rotate, 0.4)
val -= 2
sizez += 1
sizex += 1
sideval += 0.5
game.Debris:AddItem(Shard,5)
spawn(function()
wait(.5)
local tweenInfo = TweenInfo.new(
.3,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local properties = {CFrame = Shard.CFrame * CFrame.new(0, up ^ 1.5,0)}
local Tween = TweenService:Create(Shard, tweenInfo, properties)
Tween:Play()
end)
end
for i = 1, 50, 1 do
Ice()
wait()
end
local DamageDebounce = {}
for _,v in pairs(Shards) do
spawn(function()
v.Touched:Connect(function(hit)
local char = player.Character
if hit:IsDescendantOf(char) and hit:FindFirstAncestorOfClass("Model") then
if hit:FindFirstAncestorOfClass("Model").Name ~= vfx_player.Name then
if not table.find(DamageDebounce, hit:FindFirstAncestorOfClass("Model")) then
table.insert(DamageDebounce, hit:FindFirstAncestorOfClass("Model"))
hit:FindFirstAncestorOfClass("Model"):FindFirstChild("Humanoid"):TakeDamage(vfx_Damage)
end
end
end
end)
end)
end
end)
I would recommend disconnecting the listeners in the shards when they have been touched or after a delay. This is so threads aren’t running when uneeded.