So I'm making a game and I'm trying to make a block that when you touch it, a script inserts a point light into the person who touched it's torso, but only that person can see it and no one else can see the light. So far the system I have set up has one server script in the part that, when the player touches the part, a remote event is activated for only their client. Then I have a local script inside the part that waits for the remote event and then is supposed to teleport the player and insert the point light. However, it does nothing. What should I do to fix this and/or how should I go about doing this?
Server Script
local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("playerLight")
script.Parent.Touched:connect(function(hit)
remote:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent), hit)
end)
Local Script
local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("playerLight")
remote.OnClientEvent:connect(function(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
hit.Parent:MoveTo(Vector3.new(44.526, -287.545, 1625.304))
local playerLight = script.Parent.PointLight:Clone()
playerLight.Parent = hit.Parent.Torso
end
end)

1 comment
connect is deprecated, and use Connect. Also use SetPrimaryPartCFrame instead of MoveTo