Why does roblox's collision system go off with the Touched function?
Asked by
7 years ago Edited 7 years ago
I've made a script and it is supposed to CFrame a part to a Player's torso(yes he part does have CanCollide off), but for whatever reason as soon as I set a touch function the part goes above the Player's head as if CanCollide is on.Is there anyway to get around this or is it just my code?
01 | local BE = game:GetService( "ReplicatedStorage" ).Jobs.Blind |
02 | local TweenService = game:GetService( "TweenService" ) |
03 | local function Touched(Hit) |
04 | if Hit.Parent:FindFirstChild( "Humanoid" ) or Hit.Parent.Parent:FindFirstChild( "Humanoid" ) then |
05 | local x = Hit.Parent:FindFirstChild( "Humanoid" ) or Hit.Parent.Parent:FindFirstChild( "Humanoid" ) |
06 | local Found = game:GetService( "Players" ).GetPlayerFromCharacter(x) |
08 | local Gui = Instance.new( "ScreenGui" ) |
09 | local Frame = Instance.new( "Frame" ) |
10 | Frame.BackgroundColor 3 = Color 3. fromRGB( 255 , 255 , 255 ) |
11 | Frame.Size = UDim 2. new( 1 , 0 , 1 , 0 ) |
13 | Gui.Parent = Found.PlayerGui |
14 | game:GetService( "Debris" ):AddItem(Gui, 5 ) |
19 | BE.OnServerEvent:Connect( function (Player) |
20 | local Ball = Instance.new( "Part" ) |
21 | Ball.Color = Color 3. fromRGB( 255 , 255 , 255 ) |
22 | Ball.Material = "Neon" |
25 | Ball.CanCollide = false |
26 | Ball.CFrame = Player.Character.Torso.CFrame |
29 | Goal.Size = Vector 3. new( 60.81 , 60.81 , 60.81 ) |
31 | Ball.Parent = Player.Character |
32 | Player.Character.Torso.Anchored = true |
34 | local Info = TweenInfo.new( 1 , Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 3 , true ) |
35 | local Tween = TweenService:Create(Ball, Info, Goal) |
37 | Ball.Touched:Connect(Touched) |
42 | Player.Character.Torso.Anchored = false |
Before Touched function
After