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

another error? Attempt to connect failed: Passed value is not a function

script:

local raceScriptEvent = Instance.new("RemoteEvent")
raceScriptEvent.Parent = game.ReplicatedStorage
raceScriptEvent.Name = "RaceScriptEvent"

--Genorates a random number
local rand = Random.new()

function onRaceRunning (player)
	
	--Loads player race bool values 
	local raceRunning = game.ServerStorage.RaceAlreadyRuning.Value
	local playerIsRacing = player:WaitForChild("playerIsRacing")
	
	if (raceRunning) then
		
		if(not playerIsRacing.Value) then			
			playerIsRacing.Value = true						
		end
		
		--Spawns character at beggining of race
		local randPos = rand:NextInteger(1, 4)
		
		local nameOfTarget = "RacingSpawns" .. randPos
		player.Character:MoveTo(game.Workspace.RaceWay:FindFirstChild(nameOfTarget).Position)
		
	else
		playerIsRacing.Value = true
		game.ServerStorage.RaceAlreadyRuning.Value = true
		
		--Spawns character at beggining of race
		local randPos = rand:NextInteger(1, 4)
		local nameOfTarget = "RacingSpawns" .. randPos
		player.Character:MoveTo(game.Workspace.RaceWay:FindFirstChild(nameOfTarget).Position)
		
		local newOrb = game.ServerStorage.RacingOrb:Clone()	
		newOrb.Parent = game.Workspace
		
		
		newOrb:MoveTo(game.Workspace.RaceWay.OrbSpawnRace.Position)
		
		
	end
	
	
	
	
end

raceScriptEvent.OnServerEvent:Connect(raceScriptEvent)

1 answer

✓ Accepted answer

What? at line 49 why did you put the variable inside the parameters? lol.

local raceScriptEvent = Instance.new("RemoteEvent")
raceScriptEvent.Parent = game.ReplicatedStorage
raceScriptEvent.Name = "RaceScriptEvent"

--Genorates a random number
local rand = Random.new()

function onRaceRunning (player)

	--Loads player race bool values 
	local raceRunning = game.ServerStorage.RaceAlreadyRuning.Value
	local playerIsRacing = player:WaitForChild("playerIsRacing")

	if (raceRunning) then

		if(not playerIsRacing.Value) then           
			playerIsRacing.Value = true                     
		end

		--Spawns character at beggining of race
		local randPos = rand:NextInteger(1, 4)

		local nameOfTarget = "RacingSpawns" .. randPos
		player.Character:MoveTo(game.Workspace.RaceWay:FindFirstChild(nameOfTarget).Position)

	else
		playerIsRacing.Value = true
		game.ServerStorage.RaceAlreadyRuning.Value = true

		--Spawns character at beggining of race
		local randPos = rand:NextInteger(1, 4)
		local nameOfTarget = "RacingSpawns" .. randPos
		player.Character:MoveTo(game.Workspace.RaceWay:FindFirstChild(nameOfTarget).Position)

		local newOrb = game.ServerStorage.RacingOrb:Clone() 
		newOrb.Parent = game.Workspace


		newOrb:MoveTo(game.Workspace.RaceWay.OrbSpawnRace.Position)


	end




end

raceScriptEvent.OnServerEvent:Connect(onRaceRunning)

that should work.

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