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

Im doing roblox game where you can earn money but cant do plot selecting script can anyone help me?

Asked by 1 year ago

Hello i'am doing game where you can earn money but i can't do plot selecting roblox give me error: Workspace.function.ClaimPlotScript:31: attempt to index nil with 'Owner'

In every plot i have value that name is owner where i wan't to put with script player's username that claim's it

There's my scripts(local and server):

Server script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WorkSpace = game.Workspace
local ClaimEvent = ReplicatedStorage.ClaimEvent
local AlreadyClaimedEvent = ReplicatedStorage.AlreadyClaimedEvent
local HideGUI = ReplicatedStorage.HideGUIEvent
local Plots = WorkSpace.Plots
local SelectedPlot = nil


local function ClaimPlot(username, PlotSelect)
    print("Remote event ClaimPlot has been received.")
    if PlotSelect == 1 then
        SelectedPlot = Plots.firstplot
    elseif PlotSelect == 2 then
        SelectedPlot = Plots.secondplot
    elseif PlotSelect == 3 then
        SelectedPlot = Plots.thirdplot
    elseif PlotSelect == 4 then
        SelectedPlot = Plots.fourthplot
    elseif PlotSelect == 5 then
        SelectedPlot = Plots.fifthplot
    elseif PlotSelect == 6 then
        SelectedPlot = Plots.sixthplot
    elseif PlotSelect == 7 then
        SelectedPlot = Plots.seventhplot
    elseif PlotSelect == 8 then
        SelectedPlot = Plots.eightplot
    end

    local PlotValue = SelectedPlot.Owner.Value

    if PlotValue ~= nil then
        PlotValue = username
        HideGUI:FireClient(username)
    else
        AlreadyClaimedEvent:FireClient(username)
    end
    warn("ServerEvent completed!")

end


ClaimEvent.OnServerEvent:Connect(ClaimPlot)

Local script:

local gui = script.Parent.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ClaimEvent = ReplicatedStorage:WaitForChild("ClaimEvent")
local AlreadyClaimedEvent = ReplicatedStorage:WaitForChild("AlreadyClaimedEvent")
local HideGUIEvent = ReplicatedStorage:WaitForChild("HideGUIEvent")
local username = game.Players.LocalPlayer
local PlotSelect = "sixthplot"


script.Parent.MouseButton1Click:Connect (function(username)
    ClaimEvent:FireServer(username, PlotSelect)
    warn("Mouseclick sended to event")
end)


local function AlreadyClaimed()
    print("AlreadyClaimed event has been received.")
    game.StarterGui.alrdclaimed.Enabled = true
    wait(3)
    game.StarterGui.alrdclaimed.Enabled = false
end

local function hideGUI()
    gui.Visible = false
end

HideGUIEvent.OnClientEvent:Connect(hideGUI)
AlreadyClaimedEvent.OnClientEvent:Connect(AlreadyClaimed)

Answer this question