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

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

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

✓ Accepted answer

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)

1 comment

0

ayo dude u cool bro thanks

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