Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why my projectile wont damage ontouch?

Asked by 2 years ago

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?

2 answers

Log in to vote
0
Answered by
lamgogo 56
2 years ago
Edited 2 years ago

(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)
0
it doesn't work. half of the things are red lined. pakancina 19 — 2y
0
ohhh so maybe i forgot to put end somewhere,ill try to done the script inside studio when i bring my laptop with me lamgogo 56 — 2y
0
okay thanks anyway! pakancina 19 — 2y
0
ay man tell me the things i ask u so i can help ya better ;) lamgogo 56 — 2y
View all comments (4 more)
0
well its a ball, i want it to have limited range but also dissapear when it touches anything, including a wall or an npc pakancina 19 — 2y
0
i tried the new script. doesnt work on my projectile. for some reason it works on normal parts pakancina 19 — 2y
0
erm if ur ball is a model,then u have to make a square as the hitbox,and add the script inside that "hitbox",and i changed the script to work lamgogo 56 — 2y
0
the ball isnt a model, its just a part inside replicated storage pakancina 19 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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

0
he mean he want to make the ball can damage not can shoot:/ lamgogo 56 — 2y

Answer this question