So I am making a game for my friends where you throw eggs at each other and I’m working on making that but I’ve run into an issue: I put a dummy in to test if the egg can actually do the damage it needs to but I think since I have the egg in a tween going from the hand to where you clicked, it doesn’t actually detect it hitting the dummy. I have tried using BodyVelocity but it doesn’t do what I need it to.
Here is the code inside the egg:
local MinDamage = script.Parent.MinDamage.Value
local MaxDamage = script.Parent.MaxDamage.Value
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name ~= script.Parent.Thrower.Value then
if hit.Parent:FindFirstChild("Humanoid") then
print("Hit is not the thrower")
print(hit.Parent)
local Damage = math.random(MinDamage, MaxDamage)
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - Damage
script.Parent:Destroy()
end
else
print("Thrower touched")
end
end)
And here is the actual throw server script:
local TweenService = game:GetService("TweenService")
local function CreateInfo(Duration)
local tweenInfo = TweenInfo.new(
Duration,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
return tweenInfo
end
local function onThrow(player, EndPos, StartPos)
local Ball = game.ReplicatedStorage.Egg:Clone()
Ball.CFrame = StartPos
Ball.Parent = workspace
Ball.Thrower.Value = player.Name
local tweenInfo = CreateInfo((EndPos.p - StartPos.p).Magnitude / 100)
local tween = TweenService:Create(Ball, tweenInfo, {CFrame = EndPos})
tween:Play()
end
game.ReplicatedStorage.Remotes.ThrowBall.OnServerEvent:Connect(onThrow)
If anyone can give suggestions on what I can do it would be much appreciated. If I wasn’t clear on what I was trying to accomplish, I’m just trying to make it so when you click you throw and egg at that position but it doesn’t fire the touched event and I think its because I’m using tweening.