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

Race code giving an error i've never seen before? [2 Codes]

Asked by
R_alatch 394 Moderation Voter
8 years ago

So, basically, I'm getting the error "Value cannot be assigned to Script 'Workspace.Map1.Finish.Control', Line 3". I've never gotten this error, and could use some help.

So, first this is the main code:

wait(2)

local GameMaps = {}

function Update(text)
    for i, player in pairs(game.Players:GetPlayers()) do
        player.PlayerGui.Display.MainFrame:WaitForChild("Text").Text = tostring(text)
    end
end

for i, games in pairs(game.ServerStorage.Maps:GetChildren()) do
    table.insert(GameMaps, #GameMaps + 1, games.Name)
end

repeat wait(1) until game.Players.NumPlayers > 0

Update("Welcome to motioning_relatch's Race!")
wait(3)
Update("Lets start by choosing a random map.")
wait(3)

MapName = GameMaps[math.random(1, #GameMaps)]
Map = game.ServerStorage.Maps:FindFirstChild(MapName)
MapClone = Map:Clone()
           MapClone.Parent = workspace

wait(3)
Update("The map is " .. Map.Name .. " created by " .. Map:FindFirstChild("Owner").Value .. "!")
wait(3)
Update("Teleporting players to the map.")
wait(3)

for i, player in pairs(game.Players:GetPlayers()) do
    player.Character:FindFirstChild("Torso").Anchored = true
    local Spawn = math.random(1, 3)

    if Spawn == 1 then
        player.Character:MoveTo(MapClone:FindFirstChild("Spawn1").Position)
        local Spawn = math.random(1, 3)
    elseif Spawn == 2 then
        player.Character:MoveTo(MapClone:FindFirstChild("Spawn2").Position)
        local Spawn = math.random(1, 3)
    elseif Spawn == 3 then
        player.Character:MoveTo(MapClone:FindFirstChild("Spawn3").Position)
        local Spawn = math.random(1, 3)
    end
end

Update("All players have been teleported to the map.")
wait(3)
Update("Instructions: Race eachother to the end to win!")
wait(3)

for i = 3, 1, - 1 do
    Update(i)
    wait(1)
end

Update("Begin!")

for i, player in pairs(game.Players:GetPlayers()) do
    player.Character:FindFirstChild("Torso").Anchored = false
end

repeat wait(0.4) until MapClone.Finish.Touched == true
Update("The winner of the race was " .. MapClone:FindFirstChild("Winner").Value .. " who will recieve 100 points!")

WinnerPlayer = game.Players:FindFirstChild(MapClone:FindFirstChild("Winner").Value)
WinnerPlayer:FindFirstChild("leaderstats").Points.Value  = WinnerPlayer:FindFirstChild("leaderstats").Points.Value + 100
wait(3)
Update("Destroying current map.")
MapClone:Destroy

Next, we have this code for the control:

script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        script.Parent.Touched.Value = true
        script.Parent:FindFirstChild("Winner").Value = hit.Parent.Name
    end
end)

Help?

Answer this question