Hello! I’ve been trying to get a touched event to work on a serverscript the past hour or so, but I just can’t get it to work. Does anyone know why this touched event isn’t firing? The part is unanchored and often has a bodyvelocity moving it.
script.Parent.Touched:Connect(function(hit) -- this isn't firing
if hit.Parent:FindFirstChild('Humaniod') then
if hit.Parent:FindFirstChild('inGame') and hit.Parent:FindFirstChild('inGame').Value==true then
local hitPlr = game.Players:GetPlayerFromCharacter(hit.Parent)
print(hitPlr.Name.." ("..hitPlr.DisplayName..") ".."was hit!")
hit.Parent:FindFirstChild('inGame').Value=false
hit.Parent:WaitForChild('HumanoidRootPart',2).CFrame=workspace:WaitForChild('loseTp').CFrame
end
end
end)
script.Parent.Interaction.Triggered:Connect(function(player)
game:GetService("ReplicatedStorage").fn:FireClient(player,"1")
game:GetService("ReplicatedStorage").fn:FireClient(player,"3")
local vel=Instance.new("BodyVelocity",workspace:WaitForChild('Ball'))
vel.MaxForce=Vector3.new(2*math.huge,2*math.huge,2*math.huge)
script.Parent.Highlight.Enabled=true
local TweenService = game:GetService("TweenService")
script.Parent.Highlight.OutlineTransparency=0
TweenService:Create(script.Parent.Highlight,TweenInfo.new(2),{OutlineTransparency=1}):Play()
vel.P=10000
vel.Velocity=player.Character.HumanoidRootPart.CFrame.lookVector*math.random(47,61)
workspace:WaitForChild('Ball'):WaitForChild('HitEffects')[math.random(1,#workspace:WaitForChild('Ball'):WaitForChild('HitEffects'):GetChildren())]:Play()
game:GetService("ReplicatedStorage").fn:FireClient(player,"2")
game:GetService('Debris'):AddItem(vel,0.1)
end)
I’ve tried using a LocalScript and it still won’t fire. Any help appreciated, thank you!!