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

Why does roblox's collision system go off with the Touched function?

Asked by
farrizbb 465 Moderation Voter
6 years ago
Edited 6 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?

local BE = game:GetService("ReplicatedStorage").Jobs.Blind
local TweenService = game:GetService("TweenService")
local function Touched(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid") then
        local x = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
        local Found = game:GetService("Players").GetPlayerFromCharacter(x)
        print(Found.Name)
        local Gui = Instance.new("ScreenGui")
        local Frame = Instance.new("Frame")
        Frame.BackgroundColor3 = Color3.fromRGB(255,255,255)
        Frame.Size = UDim2.new(1,0,1,0)
        Frame.Parent = Gui
        Gui.Parent = Found.PlayerGui
        game:GetService("Debris"):AddItem(Gui,5)
    end
end


BE.OnServerEvent:Connect(function(Player)
    local Ball = Instance.new("Part")
    Ball.Color = Color3.fromRGB(255,255,255)
    Ball.Material = "Neon"
    Ball.Anchored = true
    Ball.Shape = "Ball"
    Ball.CanCollide = false
    Ball.CFrame = Player.Character.Torso.CFrame

    local Goal = {}
    Goal.Size = Vector3.new(60.81, 60.81, 60.81)

    Ball.Parent = Player.Character
    Player.Character.Torso.Anchored = true

    local Info = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 3, true)       
    local Tween = TweenService:Create(Ball, Info, Goal)

    Ball.Touched:Connect(Touched)       

    Tween:Play()

    wait(3)
    Player.Character.Torso.Anchored = false
    Ball:Destroy()

Before Touched function

After

0
You cannot simply make the torso non-collidable. hiimgoodpack 2009 — 6y
0
I meant the part............... farrizbb 465 — 6y
0
That is strange... I don't suppose running a for loop to check player distances is possible instead of this? whenallthepigsfly 541 — 6y
0
I wonder if you've found a bug! Regardless, a fix might be to listen to a RenderStepped/Heartbeat event and to re-CFrame the sphere back where you want it (and then disconnect the event when the Tween is finished) chess123mate 5873 — 6y
View all comments (2 more)
0
I don't think there is a reason to do a disconnect , since it automatically disconnects the function when i destroy the Part. farrizbb 465 — 6y
0
I've gotten no luck with the Heart beat but thanks for trying to help me. farrizbb 465 — 6y

Answer this question