Local Scripts don’t work in Workspace.
Put the localscript in StarterGui
. Even though it is not parented to the part it can still do the Touched
function.
Nope, its still not working .
Can you specify how can I implement it?
What is stopping you to put it inside things such as StarterCharacterScripts you don’t need to have the script right under the object.
Is this a roblox event? If not then that may be the problem if the code won’t run try adding print statements inside of the functions and let me know if it prints anything.
I know that I can use Local Scripts
, but still I want to use a Script
instead because it is particularly useful for my mechanics.
Well, it is indeed a Roblox Event
.
Ok cool I had no idea, my code used to be so cluttered when sorting proximity based guis thanks I learned something today. Now ima go change all those cluttered scripts of mine.
Both are not working . The :GetPropertyChangedSignal()
event is not even triggering when the property is changed
You 100% can use run service in a server script. I use it all the time like RunService:IsInStudio for my data stores.
Do the .Changed instead because that doesn’t require anything to be passed though the brackets.
Both .Changed
& :GetPropertyChangedSignal()
are not working as the events are not even triggered from me changing the value of enableInteractions
.
I might have found it. You should make sure the thing that hits the brick is an actual player, not just the baseplate or part of the terrain
local collider = script.Parent
local npc = collider.Parent
local playerInRange = collider.playerInRange
local enableInteractions = npc.enableInteractions
local npcID = npc.npcID
local function onTouched(hit)
if enableInteractions.Value and hit.Parent:FindFirstChildWhichIsA("Humanoid") then
playerInRange.Value = true
end
end
local function onTouchEnded(left)
if left.Parent:FindFirstChildWhichIsA("Humanoid") then
playerInRange.Value = false
end
end
collider.Touched:Connect(onTouched)
collider.TouchEnded:Connect(onTouchEnded)
Well, thanks for writing the code but its not working as the issue is that if I change the value of the bool, its not being detected in the script.Even if it works, there is 1 mistake, if a accessory’s child hits the part (which it often does), then the if statement will not pass it.
I think your problem is not the code but the “collider” part itself please try to switch the code to Magnitude instead of Touched events.
I can give you simple test place if you want.
Uhh, to be honest, I just found out about the Magnitude so I really don’t know how to implement it.