Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Remote help on a solution that can effect other blocks/npcs?

I'm not exactly sure on how to use remotes, so I believe i need some help regarding players and remote events.

local remote=Instance.new("RemoteEvent",game.ReplicatedStorage.Remotes)
remote.Name="Teleport2"

remote.OnServerEvent:connect(function(target,cframe)
	target.CFrame=cframe
end)

I searched this up, and apparently we need a player to do this remote fire, but I don't need a player as the remote is being fired from a local script to change the cframe of the part. The code within the local script is:

game.ReplicatedStorage.Remotes.Teleport2:FireServer(target.ability5torso.CFrame,target.HumanoidRootPart)

Some other things that I may list are the fact that the "ability5torso" is a block that is created within the localscript as well.

local proj = game.ReplicatedStorage.Classes.Effects.Ability5.ability5torso:Clone()
proj.CFrame = p.CFrame
proj.Parent = target

I need a solution that can effect other blocks/npcs, not only characters connected to players.

1 answer

I believe on line 4: "remote.OnServerEvent:connect(function(target,cframe)" You are missing the player. Its a default thing you don't script in your self. so you could fix this most likely, by changing the script to:

local remote=Instance.new("RemoteEvent",game.ReplicatedStorage.Remotes)
remote.Name="Teleport2"

remote.OnServerEvent:connect(function(player, target, cframe)
    target.CFrame=cframe
end)

2 comments

0

:connect is deprecated, use :Connect

0

Thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.