Hello! I’m trying to make one of the Hardest Obbies on ROBLOX, I’m making locations like the bottom and top of the mountain, So I’m making GUI Notifications.
Whenever I call the Coroutine.wrap I get this error
09:26:33.670 Workspace.NubblyFry.CheckPointScript:16: Argument 1 missing or nil - Client - CheckPointScript:16
09:26:33.671 Stack Begin - Studio
09:26:33.672 Script 'Workspace.NubblyFry.CheckPointScript', Line 16 - Studio - CheckPointScript:16
09:26:33.675 Stack End - Studio
09:26:38.239 0.5, 0.5 - Server
09:26:39.006 0.5, 0.5 - Client
Here is the Script:
local Character = script.Parent
local Head = script.Parent:WaitForChild("Head")
local Torso = script.Parent:WaitForChild("Torso")
local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
local LeftLeg = script.Parent:WaitForChild("Left Leg")
local RightLeg = script.Parent:WaitForChild("Right Leg")
local LeftArm = script.Parent:WaitForChild("Left Arm")
local RightArm = script.Parent:WaitForChild("Right Arm")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CheckPoint1Event = ReplicatedStorage:WaitForChild("CheckPoint1Event")
local CheckPointMSG1 = coroutine.wrap(function()
CheckPoint1Event:FireClient()
end)
LeftLeg.Touched:Connect(CheckPointMSG1())
RightLeg.Touched:Connect(CheckPointMSG1())
When I changed it to this, it still didn’t work for some reason
09:45:03.408 Argument 1 missing or nil - Client - CheckPointScript:14
local Character = script.Parent
local Head = script.Parent:WaitForChild("Head")
local Torso = script.Parent:WaitForChild("Torso")
local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
local LeftLeg = script.Parent:WaitForChild("Left Leg")
local RightLeg = script.Parent:WaitForChild("Right Leg")
local LeftArm = script.Parent:WaitForChild("Left Arm")
local RightArm = script.Parent:WaitForChild("Right Arm")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CheckPoint1Event = ReplicatedStorage:WaitForChild("CheckPoint1Event")
local function LegsTouched(hit)
if hit.Name == "SpawnLocation" then
CheckPoint1Event:FireClient() - Line 14
end
end
LeftLeg.Touched:Connect(LegsTouched)
RightLeg.Touched:Connect(LegsTouched)
That’s the problem, just connect it in as a normal function
function CheckPointMSG1()
CheckPoint1Event:FireClient()
end
LeftLeg.Touched:Connect(CheckPointMSG1)
RightLeg.Touched:Connect(CheckPointMSG1)
or put the coroutine inside if necessary
function CheckPointMSG1()
coroutine.wrap(function()
CheckPoint1Event:FireClient()
end)()
end
LeftLeg.Touched:Connect(CheckPointMSG1)
RightLeg.Touched:Connect(CheckPointMSG1)
Creating a coroutine is like creating another lane on a highway. If one lane gets blocked, the other ones are unaffected.
It is unnecessary to make a coroutine for running something that doesn’t block. (You don’t need a coroutine in the first place.)
However, if you want an answer to this then, @SOTR654 was correct, parantheses should not be present in the :Connect() function!
Also it is not clever to connect .Touched() to a remote without a debounce or cooldown because Touched can fire lots of times a second
Just like it says, you failed to provide an argument that was expected to be there. You called FireClient but it doesn’t know which client you want to fire it on.
Inside the parantheses of FireClient() you need to specify a Player. (Client = Player)
But I need to check if the part that it hit is the spawn location in specific, else if I just used that everywhere I go the Event would fire for the client.
local function LegsTouched(hit)
if hit.Name == "SpawnLocation" then
CheckPoint1Event:FireClient()
end
end
You aren’t passing a parameter to FireClient. FireClient isn’t asynchronous either so I don’t know why you’d want to create a separate thread anyway. You should also handle your .Touched events on the client and just handle everything relating to the leg touches in a single script but it’s up to you.
Anyway, I assume you’re trying to get the player from the script’s parent. You also should add a debounce
local players = game:GetService('Players')
local player = players:GetPlayerFromCharacter(script.Parent)
local checkpoint1Touched = false
local function checkpointMsg1(hit)
if checkpoint1Touched then
return
end
checkpoint1Touched = true
checkPoint1Event:FireClient(player)
end
rightLeg.Touched:Connect(checkpointMsg1)
leftLeg.Touched:Connect(checkpointMsg1)