hello. i have been making a projectile shooting mechanism. works preety fine! localscript:
local sound = script.fire local tweenservice = game:GetService("TweenService") local plr = game.Players.LocalPlayer
local tear1 = game.ReplicatedStorage.Player1tear local UIS = game:GetService("UserInputService") UIS.InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.E then print("Working") sound:Play() local clonetear = tear1:Clone() clonetear.Parent = game.Workspace clonetear.CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.lookVector * 5 tweenservice:Create(clonetear,TweenInfo.new(1,0,0),{CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.lookVector * 40,Transparency = 1},Enum.EasingStyle.Quint,Enum.EasingDirection.Out):Play() end end)
keep in mind, i keep the projectile in replicatedstorage. now i wanna make the projectiles actually damage on touch. for some reason, this doesnt work. any help?
(This code allow the ball to get deleted after hitting players or any parts)
script.parent.Touched:Connect(function(hit) if hit.parent:FindFirstChild("Humanoid") then hit.Parent:FindFirstChild("Humanoid"):TakeDamage() -- put the number of health u want to make player lose in this bracket wait() game.Debris:AddItem(0,script.Parent) end end else game.Debris:AddItem(0,script.Parent) end end)
so ur ball is just a part,u just need to put this script inside that ball,it still work tho. and about how to make the ball dissapear after launched,this is the full code:
local sound = script.fire local tweenservice = game:GetService("TweenService") local plr = game.Players.LocalPlayer local tear1 = game.ReplicatedStorage.Player1tear local UIS = game:GetService("UserInputService") UIS.InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.E then print("Working") sound:Play() local clonetear = tear1:Clone() clonetear.Parent = game.Workspace clonetear.CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.lookVector * 5 tweenservice:Create(clonetear,TweenInfo.new(1,0,0),{CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.lookVector * 40,Transparency = 1},Enum.EasingStyle.Quint,Enum.EasingDirection.Out):Play() game.Debris:AddItem(2.5,clonetear) -- change the number of time to wait until the ball dissapear,this can be the ball range untill get deleted end end)
asking for a script that shoots the ball?
local sound = script.fire local tweenservice = game:GetService("TweenService") local plr = game.Players.LocalPlayer local tear1 = game.ReplicatedStorage.Player1tear local UIS = game:GetService("UserInputService") UIS.InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.E then print("Working") sound:Play() local clonetear = tear1:Clone() clonetear.Parent = game.Workspace clonetear.CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.lookVector * 5 tweenservice:Create(clonetear,TweenInfo.new(1,0,0),{CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.lookVector * 40,Transparency = 1},Enum.EasingStyle.Quint,Enum.EasingDirection.Out):Play() end end)
there. keep in mind theres a sound inside the localscript, the projectile(ball) is called Player1tear