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

i made a RemoteEvent and failed so whats wrong with my script?

Asked by 3 years ago

Hey I am making SCP 173 and i am trying to connect from client to server using RemoteEvent(i havent use remoteevent before so i tried to make remoteevent) and heres the script on StarterCharacterScript:

local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local npc = workspace.NPC
local character = game.Players.LocalPlayer.Character
local remoteEvent = ReplicatedStorage:WaitForChild("see")


RunService.RenderStepped:Connect(function()
    local npcToCharacter = npc.Head.CFrame.LookVector
    local npcLook = (character.Head.Position - npc.Head.Position).Unit

    local dotProduct = npcToCharacter:Dot(npcLook)

    print(dotProduct)

    if dotProduct > .5 then
        workspace.Baseplate.BrickColor = BrickColor.new("Black")
        remoteEvent:FireServer()
        print("sees")
    else
        workspace.Baseplate.BrickColor = BrickColor.new("Baby blue")
    end
end)

script is from https://www.youtube.com/watch?v=BUwAcW_18Ws and i modified it to be more like SCP 173 i am trying to connect from client to server using remote event on the replicatedstorage so heres the second script(ServerScriptService):

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("see")

game.Workspace.NPC.Follow.Disabled = false


remoteEvent.OnServerEvent:Connect()

i am trying to connect from client to server and the output said 2 errors: 1.attempt to call nil a value 2.Attempt to connect failed:Passed value is not a function

1 answer

Log in to vote
0
Answered by 3 years ago

You forgot to put a function and attach/connect it to the remote event.

local ReplicatedStorage = game:GetService("ReplicatedStorage") 
local remoteEvent = ReplicatedStorage:WaitForChild("see")
game.Workspace.NPC.Follow.Disabled = false

function onServerEvent(player)
    -- i have no idea where to put this you need to put this on your own
end

remoteEvent.OnServerEvent:Connect(onServerEvent)
0
ayo dude u cool bro thanks skeletonpiratejack 13 — 3y
Ad

Answer this question