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

how do I use a local script to see if a part is touched? [FE]

Asked by 6 years ago

I have a hammer (tool) in the starter pack. Inside that I have a part and a weld to make sure the part is still. Inside that part I have a local script. Inside that script I wanna do a if script.Parent.Touched event. It works fins in studio but when you play on the real game it doesn't work. I've done some testing and I figured out that it works with filtering enabled off. I guess that means a local script can't use the touched event with FE on. Can I use a normal script in the tool. I have thing that you can hammer on all over the map. But because its so many of them I cant have 1 script in all of them. So how am I gonna do this?

2 answers

Log in to vote
0
Answered by
Kryptio 19
6 years ago
Edited 6 years ago

If I am wrong anyone can correct me on this, but Local Scripts do not work in the Workspace, if I am understanding correctly you have a tool that has a Server Script (Regular Script) as a child of the tool and you have a Local Script (Client Script) a child of the server script. The issue is Local Script does not work if they are part of the Workspace, so when a tool is called and present in the game like you can visually see it means its part of the Workspace which also means so is the Local Script and it won't work.

So two things you can do you can move the Local Script to the StarterPlayerScripts and you might need to change some of the internal functions around so it will react to the Tool in your Workspace or just copy and paste everything from the Local Script to a Server Script and it will work on the server.

If you want everyone to see the hammer being used then use the Server Script, and if not then use the Local Script so that only the client (only the user of the hammer) sees it. Honestly though if you don't have a preference and you just need this to work I would use the Server Script if you are struggling until you get used to working with Local Scripts.

Hope this helps!

0
thx man Nilsen84 1 — 6y
Ad
Log in to vote
0
Answered by
Meqolo 78
6 years ago

You don't use a local script, you use a server script.

Answer this question