so here's my code in a localscript which is in a part which is in a model called fuzzy1. I had it in a normal script but when someone touches it, it goes away for all the players but I only want it to go away for the player who touched it so I put my code in a local script. Can anyone help me?
function OnTouch(hit) wait(0.01) local value = script.Parent.Position local x, y, z = value.x, value.y, value.z x, y, z = -15.51, -7.834, 0.07 script.Parent.Position = Vector3.new(x, y, z) game.workspace.Fuzzy1.Eye1.Position = Vector3.new(x, y, z) game.workspace.Fuzzy1.Eye2.Position = Vector3.new(x, y, z) game.workspace.Fuzzy1.FuzzyMesh.Position = Vector3.new(x, y, z) end script.Parent.Touched:Connect(OnTouch)
In your case, it has to do with the type of script you're using.
LocalScripts don't run in Workspace and are usually put in the character and the player. If you simply change your script type to a Script, which does run in Workspace, it should work.
You should also look into a more intuitive way of teleporting the player, as your code raises some questions. For example, why set the variables to the X, Y and Z positions of value, only to be immediately overwritten?
Addressing your issue of you wanting it to be a local change, you should consider moving the LocalScript over to StarterPlayerScripts, and changing script.Parent
to workspace.whateverpartyoureteleportingto
.
If anything comes up, shoot me a DM on Discord, @artblart#3386, and I'll be happy to help.
to help you with your question and solving it. you would have to move your local script into player gui. when you move it there and if its a local script it will only change things on your screen or the local players screen and not others. kind of like when you use guis with local scripts if you open a gui or something it doesnt happen on everybody else screen.. just yours.