Hey everyone, i wrote this very simple script to print the name of the part the green sphere is touching but it’s not working…
The green sphere is a part of the player and i have a server script inside of it but the code won’t work.
Here’s the code
script.Parent.Touched:Connect(function(touched)
print(touched.Name)
end)
i tried using events i tried using local scripts i tried putting the part outside the player but nothing seemed to work.
8 Likes
Are they both anchored?
.Touched doesn’t work if both are anchored
3 Likes
The green sphere isn’t anchored if that’s what you mean
2 Likes
Wigglyaa
(Wigglyaa)
June 8, 2023, 2:03pm
#4
Try changing it to a local script.
(Sorry missed the line where you said you’d tried that)
Have you checked that CanTouch is true?
2 Likes
yeah already checked that, it’s been true the entire time.
2 Likes
Wait just to confirm, the player and the sphere are not anchored right?
2 Likes
No nothing in the character is anchored, but the part i’m trying to touch are.
2 Likes
the print works fine when i use a dummy in the workspace but it doesn’t work when i play with the character
2 Likes
Do you Instance.new the sphere or do you do something else to get the green sphere?
2 Likes
the green sphere is within the character model already (it’s ColSphere)
The script does not run
Try parenting the script to StarterCharacterScripts and do this instead:
script.Parent:WaitForChild('ColSphere').Touched:Connect(function(TouchPart) print(TouchPart) end)
1 Like
i can’t do that since i’m using a “false character” the real character is just an invisible ball so which doesn’t contain the sphere so i can’t use starter character scripts
1 Like
It still works on that case
You can still parent a script to startercharacterscripts to fetch the part
1 Like
i’ll give it a try and let you know what happens
nope still not working, same problem.
1 Like
Is there any output?
I’m very sure if you parent it to startercharacterscripts, it will run
1 Like
nope nothing in the output, is there any other way other than startercharacterscripts?
1 Like
Update! i got a red sphere (in workspace) with the same script as the green sphere
and when the red one touches me it prints out meaning it’s the green sphere’s script that’s not working so maybe it has something to do with the fact that it starts out in replicated storage or something?
Depends on your use case
You may want to parent a localscript to StarterPlayerScripts or a script in ServerScriptService
1 Like
Uhm
Check if the script is parented to the character after the player spawns in
1 Like