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

I keep getting an error saying "WinValue is not a valid member of Player" Whats wrong?

Asked by 4 years ago
Edited 4 years ago

I'm trying to make a part that if you step on it gives you a win and then teleports you to the start. The thing is it would give you 2 or 3 wins if you touched it. So this is my solution, and I'm having problems. Anybody know what's wrong?

WinScript, game.Workspace.WinPart.WinScript(server script)

local WinPart = script.Parent

WinPart.Touched:Connect(function(hit)   
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")

    local BoolVal = player.BoolVal

    if player then

        if BoolVal.Value == true then

            local leaderstats = player:FindFirstChild("leaderstats")

            if leaderstats then

                    local Player = game.Players.LocalPlayer

                    local Location = game.Workspace.TeleportLocation
                    local RepStore = game:GetService("ReplicatedStorage")
                    local WinValue = game.ReplicatedStorage.WinValue

                    local clone = WinValue
                    clone.Parent = Player
                    clone.Name = WinValue

                    WinValue.Value = true

                    hit.Parent.HumanoidRootPart.CFrame =  CFrame.new(Location.Position)

                    wait(1)

            end
        end
    end
end)

LocalWinGiver, game.StarterPlayer.StarterPlayerScripts.LocalWinGiver(local script)

local RepStore = game:GetService("ReplicatedStorage")
local WinValue = RepStore.WinValue

local player = game.Players.LocalPlayer

local PlayerWinVal = player.WinValue

WinValue.Value = false

while true do
    wait(1)
    if PlayerWinVal.Value == true then
        player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
        PlayerWinVal.Value = false
    end

end
1
it's literally in english. win value isnt in the player di5z 11 — 4y
0
I'm pretty sure it's because the touched event is used in a server script, in which game.Players.LocalPlayer is used to find the VinValue, but LocalPlayer is only accessible by a LocalScript. deeskaalstickman649 475 — 4y

Answer this question