Hello,
I am creating my soccer game on roblox and I am developing a goalkeeper mode I made a script that allows you to take the ball,
I tested and I had a problem when I take the ball in my hand and I click and its put me “Workspace is not a valid member of Workspace” Workspace "I saw whole pages of forum and its not helping me
Code:local dropped = false
script.Parent.Activated:Connect(function()
if dropped == false then
local plr = nil
dropped = true
local Ballc = script.Parent
plr = script.Parent.Parent.Parent
wait(0.0001)
print(plr.Name)
local f = 0
for i,v in pairs(game.Workspace.Players.Blue:GetChildren()) do
if v.Name == plr.Name then
f = “Blue”
end
end
for i,v in pairs(game.Workspace.Players.Red:GetChildren()) do
if v.Name == plr.Name then
if f == 0 then
f = “Red”
end
end
end
if f == “Blue” then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
elseif f == “Red” then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
end
game.Workspace.SoccerBall.SoccerBall.Position = game.Workspace[plr.Name].Head.Position + Vector3.new(3,0,0)
game.Workspace.SoccerBall.SoccerBall.Transparency = 0
game.Workspace.SoccerBall.SoccerBall.Anchored = false
game.Workspace.SoccerBall.SoccerBall.CanCollide = true
wait(0.001)
local Script = script
Script.Parent = game.Workspace
Ballc:Destroy()
wait(6)
if f == 1 then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = false
else
game.Workspace.Players.Red[plr.Name].BallDropped.Value = false
end
script:Destroy()
end
end)
while script.Parent.Parent.Name == “Backpack” do
wait(5)
if dropped == false then
local plr = nil
dropped = true
local Ballc = script.Parent
plr = script.Parent.Parent.Parent.Parent
wait(0.0001)
local f = 0
for i,v in pairs(game.Workspace.Players.Blue:GetChildren()) do
if v.Name == plr.Name then
f = “Blue”
end
end
for i,v in pairs(game.Workspace.Players.Red:GetChildren()) do
if v.Name == plr.Name then
if f == 0 then
f = “Red”
end
end
end
if f == “Blue” then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
elseif f == “Red” then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
end
game.Workspace.SoccerBall.SoccerBall.Position = plr.Character.Head.Position + Vector3.new(3,0,0)
game.Workspace.SoccerBall.SoccerBall.Transparency = 0
game.Workspace.SoccerBall.SoccerBall.Anchored = false
game.Workspace.SoccerBall.SoccerBall.CanCollide = true
local Script = script
Script.Parent = game.Workspace
Ballc:Destroy()
wait(6)
if f == 1 then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = false
else
game.Workspace.Players.Red[plr.Name].BallDropped.Value = false
end
script:Destroy()
end
end
local dropped = false
script.Parent.Activated:Connect(function()
if dropped == false then
local plr = nil
dropped = true
local Ballc = script.Parent
plr = script.Parent.Parent.Parent
wait(0.0001)
print(plr.Name)
local f = 0
for i,v in pairs(game.Workspace.Players.Blue:GetChildren()) do
if v.Name == plr.Name then
f = “Blue”
end
end
for i,v in pairs(game.Workspace.Players.Red:GetChildren()) do
if v.Name == plr.Name then
if f == 0 then
f = “Red”
end
end
end
if f == “Blue” then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
elseif f == “Red” then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
end
game.Workspace.SoccerBall.SoccerBall.Position = game.Workspace[plr.Name].Head.Position + Vector3.new(3,0,0)
game.Workspace.SoccerBall.SoccerBall.Transparency = 0
game.Workspace.SoccerBall.SoccerBall.Anchored = false
game.Workspace.SoccerBall.SoccerBall.CanCollide = true
wait(0.001)
local Script = script
Script.Parent = game.Workspace
Ballc:Destroy()
wait(6)
if f == 1 then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = false
else
game.Workspace.Players.Red[plr.Name].BallDropped.Value = false
end
script:Destroy()
end
end)
while script.Parent.Parent.Name == “Backpack” do
wait(5)
if dropped == false then
local plr = nil
dropped = true
local Ballc = script.Parent
plr = script.Parent.Parent.Parent.Parent
wait(0.0001)
local f = 0
for i,v in pairs(game.Workspace.Players.Blue:GetChildren()) do
if v.Name == plr.Name then
f = “Blue”
end
end
for i,v in pairs(game.Workspace.Players.Red:GetChildren()) do
if v.Name == plr.Name then
if f == 0 then
f = “Red”
end
end
end
if f == “Blue” then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
elseif f == “Red” then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
end
game.Workspace.SoccerBall.SoccerBall.Position = plr.Character.Head.Position + Vector3.new(3,0,0)
game.Workspace.SoccerBall.SoccerBall.Transparency = 0
game.Workspace.SoccerBall.SoccerBall.Anchored = false
game.Workspace.SoccerBall.SoccerBall.CanCollide = true
local Script = script
Script.Parent = game.Workspace
Ballc:Destroy()
wait(6)
if f == 1 then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = false
else
game.Workspace.Players.Red[plr.Name].BallDropped.Value = false
end
script:Destroy()
end
end
it works, I can click even in my player test it works but after I re-test its my put an error "fares14213 is not a valid member of Folder ,Workspace.Players.Red "
script.Parent.Activated:Connect(function()
if dropped == false then
local plr = nil
dropped = true
local Ballc = script.Parent
plr = script.Parent.Parent
wait(0.0001)
game.Workspace.SoccerBall.SoccerBall.Position = game.Workspace[plr.Name].Head.Position + Vector3.new(3,0,0)
game.Workspace.SoccerBall.SoccerBall.Transparency = 0
game.Workspace.SoccerBall.SoccerBall.Anchored = false
game.Workspace.SoccerBall.SoccerBall.CanCollide = true
wait(0.001)
local Script = script
Script.Parent = game.Workspace
Ballc:Destroy()
plr:WaitForChild(“BallDropped”).Value = true
wait(6)
plr:WaitForChild(“BallDropped”).Value = false
script:Destroy()
end
end)
while script.Parent.Parent.Name == “Backpack” do
wait(5)
if dropped == false then
local plr = nil
dropped = true
local Ballc = script.Parent
plr = script.Parent.Parent.Parent.Parent
wait(0.0001)
game.Workspace.SoccerBall.SoccerBall.Position = plr.Character.Head.Position + Vector3.new(3,0,0)
game.Workspace.SoccerBall.SoccerBall.Transparency = 0
game.Workspace.SoccerBall.SoccerBall.Anchored = false
game.Workspace.SoccerBall.SoccerBall.CanCollide = true
local Script = script
Script.Parent = game.Workspace
Ballc:Destroy()
plr:WaitForChild(“BallDropped”).Value = true
wait(6)
plr:WaitForChild(“BallDropped”).Value = false
script:Destroy()
end
end
Error: 00:24:09.016 Infinite yield possible on ‘Workspace.fares14213:WaitForChild(“BallDropped”)’ - Studio
00:24:09.017 Stack Begin - Studio
00:24:09.017 Script ‘Players.fares14213.Backpack.Ball.Script’, Line 18
there is no error when I click it does not give it to me in my inventory here is the code:local dropped = false
script.Parent.Activated:Connect(function()
if dropped == false then
local plr = nil
dropped = true
local Ballc = script.Parent
plr = script.Parent.Parent
wait(0.0001)
print(plr.Name)
local f = 0
for i,v in pairs(game.Workspace.Players.Blue:GetChildren()) do
if v.Name == plr.Name then
f = “Blue”
end
end
for i,v in pairs(game.Workspace.Players.Red:GetChildren()) do
if v.Name == plr.Name then
if f == 0 then
f = “Red”
end
end
end
if f == “Blue” then
if game.Workspace.Players.Blue:FindFirstChild(plr.Name) then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
else
if game.Workspace.Players.Red:FindFirstChild(plr.Name) then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
end
end
elseif f == “Red” then
if game.Workspace.Players.Red:FindFirstChild(plr.Name) then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
else
if game.Workspace.Players.Blue:FindFirstChild(plr.Name) then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
end
end
end
game.Workspace.SoccerBall.SoccerBall.Position = game.Workspace[plr.Name].Head.Position + Vector3.new(3,0,0)
game.Workspace.SoccerBall.SoccerBall.Transparency = 0
game.Workspace.SoccerBall.SoccerBall.Anchored = false
game.Workspace.SoccerBall.SoccerBall.CanCollide = true
wait(0.001)
local Script = script
Script.Parent = game.Workspace
Ballc:Destroy()
wait(6)
if f == “Blue” then
if game.Workspace.Players.Blue:FindFirstChild(plr.Name) then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
else
if game.Workspace.Players.Red:FindFirstChild(plr.Name) then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
end
end
elseif f == “Red” then
if game.Workspace.Players.Red:FindFirstChild(plr.Name) then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
else
if game.Workspace.Players.Blue:FindFirstChild(plr.Name) then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
end
end
end
script:Destroy()
end
end)
while script.Parent.Parent.Name == “Backpack” do
wait(5)
if dropped == false then
local plr = nil
dropped = true
local Ballc = script.Parent
plr = script.Parent.Parent.Parent.Parent
wait(0.0001)
local f = 0
for i,v in pairs(game.Workspace.Players.Blue:GetChildren()) do
if v.Name == plr.Name then
f = “Blue”
end
end
for i,v in pairs(game.Workspace.Players.Red:GetChildren()) do
if v.Name == plr.Name then
if f == 0 then
f = “Red”
end
end
end
if f == “Blue” then
if game.Workspace.Players.Blue:FindFirstChild(plr.Name) then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
else
if game.Workspace.Players.Red:FindFirstChild(plr.Name) then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
end
end
elseif f == “Red” then
if game.Workspace.Players.Red:FindFirstChild(plr.Name) then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
else
if game.Workspace.Players.Blue:FindFirstChild(plr.Name) then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
end
end
end
game.Workspace.SoccerBall.SoccerBall.Position = plr.Character.Head.Position + Vector3.new(3,0,0)
game.Workspace.SoccerBall.SoccerBall.Transparency = 0
game.Workspace.SoccerBall.SoccerBall.Anchored = false
game.Workspace.SoccerBall.SoccerBall.CanCollide = true
local Script = script
Script.Parent = game.Workspace
Ballc:Destroy()
wait(6)
if f == “Blue” then
if game.Workspace.Players.Blue:FindFirstChild(plr.Name) then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
else
if game.Workspace.Players.Red:FindFirstChild(plr.Name) then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
end
end
elseif f == “Red” then
if game.Workspace.Players.Red:FindFirstChild(plr.Name) then
game.Workspace.Players.Red[plr.Name].BallDropped.Value = true
else
if game.Workspace.Players.Blue:FindFirstChild(plr.Name) then
game.Workspace.Players.Blue[plr.Name].BallDropped.Value = true
end
end
end
script:Destroy()
end
end
So I have had weird errors like that before (PlayerGui is not a valid member of game.Players.Lava_shield) and I fixed the issue by putting a wait(1) at the start of the script. I am not sure your issue can be fixed this easily but I would try it.