Hi. Im trying to make a Water Manipulation ability, where you send out stream of water that after touching something, should emit particles. Everything works fine except the touch function. I don’t know why, but the part flies through other blocks and then explodes, when it should be like this at the same time when it touches the other part. I also did Fire Blast and Air Blast, however they work fine. I don’t know what’s wrong with this one, even though its the same script with just different particles/parts.
you need to post the code so people can help
I second this. Section is for scripting support. Can’t really support without any code/scripts.
1 Like
yea sorry posting, forgot about it lmao
elseif info == "Water Splash" then
if info2 == "start" then
Values.WaterSplash.OnCooldown.Value = true
local anim = ReplicatedStorage.Animations.Water.WaterSplash.Animation
local loadanim = animator:LoadAnimation(anim)
local VFX = ReplicatedStorage.Blocks.Water.WaterSplash:Clone()
VFX.Owner.Value = player
local SFX = ReplicatedStorage.Sounds.Water.WaterSplash.Splash:Clone()
SFX.Parent = VFX
local SFX2 = ReplicatedStorage.Sounds.Water.WaterSplash.Splash2:Clone()
SFX2.Parent = VFX
local weld = Instance.new("WeldConstraint")
weld.Parent = VFX
weld.Part0 = VFX
weld.Part1 = character.RightHand
weld.Enabled = false
local FollowMouse = VFX.FollowMouse
FollowMouse.Value = true
local attachment = VFX.Attachment
attachment.Parent = VFX
local velocity = VFX.LinearVelocity
velocity.MaxForce = math.huge
velocity.Enabled = false
humanoid.WalkSpeed = 5
humanoid.JumpPower = 20
loadanim:Play()
loadanim:AdjustSpeed(1.15)
SFX:Play()
VFX.Parent = workspace
VFX.Position = character.RightHand.Position
VFX.Trail.Enabled = true
for i,v in VFX:GetChildren() do
if v:IsA("ParticleEmitter") then
v.Enabled = true
end
end
weld.Enabled = true
wait(.5)
CameraModule.Shake(player, "ShakeBump", true)
velocity.Enabled = true
weld.Enabled = false
VFX.CFrame = character.PrimaryPart.CFrame:ToWorldSpace(CFrame.new(1,0,-1))
local direction = character.PrimaryPart.Position - mousePos.Position
local ray = Ray.new(character.HumanoidRootPart.Position, direction)
velocity.VectorVelocity = ray.Unit.Direction * -75
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
local function DestroySplash(hit)
if VFX and VFX.CanTouch then
for i,v in VFX:GetChildren() do
if v:IsA("ParticleEmitter") then
v.Enabled = false
end
end
VFX.CanTouch = false
if not VFX then return end
attachment:Destroy()
velocity:Destroy()
VFX.Anchored = true
if not VFX:FindFirstChild("Emit") then return end
for i,v in pairs(VFX.Emit:GetChildren()) do
v:Emit(75)
end
SFX2:Play()
wait(3)
if not VFX then return end
SFX:Destroy()
VFX:Destroy()
end
end
VFX.Touched:Connect(function(hit)
if hit:FindFirstAncestorWhichIsA("Model") ~= character then
print("Touch")
print(hit.Name, hit.Parent.Name)
Values.WaterSplash.TurnedOn.Value = false
if hit:FindFirstAncestorWhichIsA("Model"):FindFirstChild("Humanoid") then
local targetchar = hit:FindFirstAncestorWhichIsA("Model")
if targetchar:FindFirstChild("Immune") then
if targetchar.Immune.WaterImmune.Value == true then
return
end
end
print(1)
targetchar.Humanoid:TakeDamage(10)
VFX.Position = hit.Position
DestroySplash()
elseif hit:FindFirstChild("Shield") then
print(2)
local shield = hit
else
print(3)
DestroySplash()
end
end
end)
Values.WaterSplash.OnCooldown.Value = true
Values.WaterSplash.TurnedOn.Value = true
wait(1.5)
Values.WaterSplash.OnCooldown.Value = false
FollowMouse.Value = false
wait(1)
DestroySplash()
if Values.WaterSplash.OnCooldown.Value then return end
Values.WaterSplash.TurnedOn.Value = false
end
You mentioned at it’s core, it’s pretty much the same code as fire blast and air blast right?
Yes it is. Just different particles and animations
Then most likely due to the part, check if certain properties are on like canCollide/canTouch, etc.
i suggest you use raycasts instead of touch events, as touch events aren’t guaranteed to work/be accurate. If you still want the projectile to travel, look up fastcast
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.