I want to see if I can fire a part’s .Touched
event on the client. I noticed that when creating a .Touched
event that a new instance named TouchInterest
gets created, but when I tried looking for information on it I could not find much about it.
I wrote this code (that does not work) as an example of what I want to achieve here, it runs through a LocalScript
anywhere on the client.
local part = workspace:WaitForChild('WOW')
part.Touched:Connect(function(otherPart: BasePart)
print('Touched by', otherPart)
end)
-- the touch interest object gets created on the client
local touchTransmitter = part:FindFirstChildOfClass('TouchTransmitter') :: TouchTransmitter
while not touchTransmitter do
touchTransmitter = part:FindFirstChildOfClass('TouchTransmitter')
task.wait(.15)
end
-- get the variable to fire the event with
local player = game:GetService('Players').LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local root = character.PrimaryPart
while not root do
character.DescendantAdded:Wait()
root = character.PrimaryPart
end
-- fire the touch event on the player's root
touchTransmitter:Touch(root) -- doesnt exist!!