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

Can't access a RemoteFunction in ReplicatedStorage?

Asked by
KoreanBBQ 301 Moderation Voter
8 years ago

I've been trying to do pathfinding for click to move. For that I need to invoke a RemoteFunction inside ReplicatedStorage, it keeps saying it can't find a RemoteFunction child under ReplicatedStorage. I tried moving it to ServerStorage, and even workspace, nothing.

Here's how I create the Remotefunction. In another script, a LocalScript, I try to invoke the RemoteFunction.

local pathfindingService = game:GetService("PathfindingService")
local pointModel = Instance.new("Model")
pointModel.Name = "Points"
pointModel.Parent = game.Workspace
local remotefunction=Instance.new("RemoteFunction")
remotefunction.Parent=game.ReplicatedStorage

And how I invoke it:

local points = workspace.RemoteFunction:InvokeServer(mouse.Hit.p)

ENTIRE SCRIPT OF WHERE I CREATE THE REMOTE

local pathfindingService = game:GetService("PathfindingService")
local pointModel = Instance.new("Model")
pointModel.Name = "Points"
pointModel.Parent = game.Workspace
local remotefunction=Instance.new("RemoteFunction")
remotefunction.Parent=game.ReplicatedStorage
remotefunction.OnServerInvoke=function(player,target)
    local start=player.Character.Torso.Position
    local path = pathfindingService:ComputeRawPathAsync(start, target, 500)
    for _, point in pairs(pointModel:GetChildren()) do
        point:Destroy()
    end

    local points = path:GetPointCoordinates()
    for _, point in pairs(points) do
        local part = Instance.new("Part")
        part.Parent = pointModel
        part.FormFactor = Enum.FormFactor.Custom
        part.Size = Vector3.new(1,1,1)
        part.Position = point
        part.Anchored = true
        part.CanCollide = false
    end
    if path.Status == Enum.PathStatus.FailStartNotEmpty or path.Status == Enum.PathStatus.FailFinishNotEmpty then
        print("Compute failed")
        return {}
    end

    return path:GetPointCoordinates()
end

Answer this question