Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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)
0
:connect is deprecated, use :Connect JeffTheEpicRobloxian 258 — 3y
0
Thank you Kilobriderozero 0 — 3y
Ad

Answer this question