Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Touched Event work through Script.Parent?

My Studio is really buggy last time... I can't use touched event in Script.Parent sometimes and sometimes I can.. I made a part and did this script which didn't work

script.Parent.Touched:Connect(function()
    print("A")
end)

I putted a script in StarterPlayerScripts which worked fine

local Mesh = game.Workspace:WaitForChild("MeshPart")

Mesh.Touched:Connect(function()
        print("H")
end)

Any idea why?

1 comment

0

Did you use a LocalScript with the first code?

1 answer

use a script in ServerScriptService

local part = game.Workspace.Part -- specify ur part
part.Touched:Connect(function(hit) -- see if its been hit
if game.Players:GetPlayerFromCharacter(hit.Parent) then -- check if its a player
    print("A") -- ur stuff
end
end)

2 comments

0

You didn't read properly. He wants to be able to have a script inside the part. And use script.Parent

0

where he specify that

This discussion is preserved as it was. New answers, comments, and votes are closed.