Touched Event not working inside local script. Why

Hey guys so I have a part that I’m using the .Touched event with in a script and a local script. But I need it inside the local script so that I can number 1 refer to the player with a localized variable and number 2, I need to fire a remote event from the local script when they touch the part, but nothing is printing when the Touched event connects inside the local script.

https://gyazo.com/66801e63406f13ca61f63f99f18fc3f7

local part = script.Parent

part.Touched:Connect(function()
	print('DBSVT')
end)

LocalScripts do not run in workspace.

Also, the BasePart.Touched event fires on the server, so there is no need to have a LocalScript over a server script. The BasePart.Touched event also gives the other part which came in contact, so therefore you can use its parent and Players:GetPlayerFromCharacter to get the player.

1 Like

Local scripts don’t work in Workspace. Put it in StarterPack, StarterGui, StarterPlayerScripts, or StarterCharacterScripts

2 Likes

So should I throw the local script into ‘StarterPlayerScripts’ and refer to part via local part = workspace.Part

Yes or just Turn it into a Server Script

1 Like

If he follows through with your solution, the best place to put it would be StarterPlayerScripts.

2 Likes
local part = workspace.Part

part.Touched:Connect(function()
	print('DBSVT')
end)

This can work as a local script if written like in the above, you would just need to place the script in a directory/parent it to an instance which allows for it to be executed (local scripts do not execute if parented to the workspace), for example; StarterPlayerScripts/StarterGui/StarterCharacterScripts etc.

1 Like