Maybe I'm just missing something and am currently too tired to realize it, but I made custom functions that create new instances. However, going to call those functions with the player parameter (since it uses it to name the parts) gives me the error "Passed value is not a function." I'm confused because I have another script with the same code that works fine, so what's the issue with this one?
#I keep getting the error "Passed value is not a function" and I'm unable to figure out why...
1 messages · Page 1 of 1 (latest)
Here's the other script that also has custom functions and works. Why does this work and the other doesn't?
Also here is the variables list which is at the top:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local cursorVars = require(game.ReplicatedStorage:WaitForChild("cursorVars"))
local range = cursorVars.range
local HRP = player.Character:WaitForChild("HumanoidRootPart")
local camera = game.Workspace.CurrentCamera
local cursorParams = RaycastParams.new()
local dot;
local line;
local color;```
why do you need to call the functions with the player parameter again
if your functions themselves don't have any args
yeah
hold on just wondering which is an argument which is a parameter
arent the parameters set when the function is defined
mixed them up. parameter is the one within the function, but it doesnt matter too much
yeah so basically when you call your function your trying to pass in a value and your function doesn’t know what to do with it
Idk the first script i made had like
function makePart()
local newPart = Instance.new("Part")
newPart.Name = (player.Name .. "'s Part")
end
function makePart(player)```
and this worked?
Well yeah
Yep and idk why
Im not understanding...
The last line just makes another function
So how do i call a function i've made beforehand
ohh yea u right. But the thing is i do that exact thing once a player's character is found, and it still doesn't work
Function = example(parameter1 ,parameter 2)
to call it
to call it
example(argument1,argument2)
you dont need these
Wdym send cod
Which part u talking about
Yeah
This screenshot includes the entirety of both functions
Which line
Alright then
I did end up trying to just put in all the parens (player) but it still didnt work
Where?
It sounds like you don’t know what a parameter is so I advise just watching a vid or looking over the docs
It’s pretty essential for functions
i added a 'player' to the functions makeDot() and makeLine(), along with when they're called after 'chars' is checked
U prolly right i may not know what im doing gg😭☠️
Adding a parameter would be makeDot(player)
Where you make the function
Try do it now and make it work and send code if u need help 😀
Good learning experience
So lines 26, 38, 47, 48
Ok
also can you copy n paste the error message here
"Passed value is not a function" doesnt seem like it'd go here
pretty sure luau would just ignore it anyways
thats a different error
and you dont need player parameter or arg in your functions when its already a variable defined above
o
even when a param isnt used in function i still get same error
the first one is new and not working, second one is old and working
the second should be disabled
can you show the blue lines under the error
i disabled script 2 yes
im using the new one cuz its organized better and requires less outside parts like models
^
** You are now Level 4! **
The ()
** You are now Level 9! **
oh that
run.RenderStepped:Connect(getMouseData())
getMouseData() uses the RETURN of the function
run.RenderStepped:Connect(getMouseData)
getMouseData uses the FUNCTION itself
i see
i forgot functions could return stuff
alright that was stupid of me but thanks
can u show the whple script
they did, and solved