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

.Touched not detecting a thrown object?

Asked by 4 years ago
Edited 4 years ago

I'm using this script to detect when a player throws an object and it would collide with the object this script is in.

script.Parent.Touched:Connect(function()
    print("part has been touched")
end)

It runs when colliding with anything but the object that is being thrown. I can't find out why this is happening. Is it because it's a cloned object or something?

Here's the part throwing script I have if that's helpful

Player = game.Players.LocalPlayer
wait(5)
Character = Player.Character
Mouse = Player:GetMouse()
Enabled = true

Mouse.KeyDown:Connect(function(key)
    if Enabled == false then return end
    key = key:lower()
    if key == "q" then

        if script.shoesLeft.Value > 0 then
            script.shoesLeft.Value = script.shoesLeft.Value - 1
        Enabled = false
        Fireball = script.placeholderShoe:Clone()
        Fireball.Parent = Character
        Fireball.CFrame = Character.UpperTorso.CFrame*CFrame.new(0,4,-5.1)
        BV = Instance.new("BodyVelocity")
        BV.MaxForce = Vector3.new(200,200,200)
        BV.Velocity = Character.UpperTorso.CFrame.lookVector*250
        BV.Parent = Fireball
        wait(.1)
        BV:Destroy()
        wait(5)
        Enabled = true


        end
    end
end)
0
You have mispelled player.. You typed in Layer. User#30811 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

The problem with your script is that you have mispelled "player".

Player = game.Players.LocalPlayer
wait(5)
Character = Player.Character
Mouse = Player:GetMouse()
Enabled = true

Mouse.KeyDown:Connect(function(key)
    if Enabled == false then return end
    key = key:lower()
    if key == "q" then

        if script.shoesLeft.Value > 0 then
            script.shoesLeft.Value = script.shoesLeft.Value - 1
        Enabled = false
        Fireball = script.placeholderShoe:Clone()
        Fireball.Parent = Character
        Fireball.CFrame = Character.UpperTorso.CFrame*CFrame.new(0,4,-5.1)
        BV = Instance.new("BodyVelocity")
        BV.MaxForce = Vector3.new(200,200,200)
        BV.Velocity = Character.UpperTorso.CFrame.lookVector*250
        BV.Parent = Fireball
        wait(.1)
        BV:Destroy()
        wait(5)
        Enabled = true


        end
    end
end)

There.

0
Oh sorry, I copied it over wrong. I did spell it correctly in my original script, and there's no issues there. The problem is that the thrown object is not being detected in the .Touched script. codee21 4 — 4y
0
Can i have a look at the .Touched script? User#30811 0 — 4y
0
yeah, it's the first one in my question codee21 4 — 4y
0
Does it print anything? User#30811 0 — 4y
Ad

Answer this question