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

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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.

Ad

Answer this question