I have an attack animation that when the player hits another player this script plays and it creates an instance that damages the player with the script that is cloned into it. My script is down below but doesn't work, any help?

--Finds Character and UserInputService
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local UserInputService = game:GetService("UserInputService")

--Debounce
local deb = true

--Creates Blast Effect.
UserInputService.InputBegan:Connect(function(input, proc)
	if not proc and input.KeyCode == Enum.KeyCode.T then
    if deb == true then return end
    deb = false
    local Blast = Instance.new("Part")
    Blast.Color = BrickColor.new("Toothpaste")
    Blast.Parent = game.Workspace
    Blast.CFrame = Character.UpperTorso.CFrame * CFrame(0,0,0)
    Blast.Shape = "Ball"
    Blast.Name = "Blast"
    wait(0.1)
    deb = true
    if game.Workspace:WaitForChild("Blast") ~= nil then
	local DamageScript = game.ReplicatedStorage:FindFirstChild("DamageScript")
	local NewScript = DamageScript:Clone()
	NewScript.Parent = game.Workspace:WaitForChild("Blast")
end
end
end)

7 comments

0

uh, set the script's Parent to another Parent? it should really be that simple

0

maybe try input ended?

0

Does the script appear in explorer?

0

Is it a local script?

0

The instance doesn't appear in explorer alongside the script and yes it is a local script

0

and MCAndRobloxUnited "NewScript.Parent = game.Workspace:WaitForChild("Blast")"

0

Just realized I had a broken debounce I fixed it now.