When creating a function, its saying this? Please help me.
local function getPlayerFromPart(part)
local character = part.Parent
if character then
local player = game.Players:GetPlayerFromCharacter(character)
return player
end
end
Edit: I am trying to follow a tutorial on how to make a tycoon. This is the full script:
local button = script.Parent
local tycoon = script.Parent.Parent.Parent
local dirtyRock = game.ReplicatedStorage.DirtyRock
local dropper = script.Parent.Parent.Dropper
local objectsFolder =
local function getPlayerFromPart(part)
local character = part.Parent
if character then
local player = game.Players:GetPlayerFromCharacter(character)
return player
end
end
local function dropObject()
local newPart = dirtyRock:Clone()
newPart.Position = dropper.Position
newPart.Parent = objectsFolder
end
local function onTouched(otherPart)
local player = getPlayerFromPart(otherPart)
if player then
dropObject()
end
end
button.Touched:Connect(onTouched)

5 comments
try just removing 'local' from line 1
When I did that, there was an error under getPlayerFromPart
what error is it? You could check if its a valid character on line 4.I think the error is just because part.Parent isn't a valid characterÂ
Is this the full script, it seems like its an error above this function.
I think i got it now, i think this was due to 'objectsFolder' not being defined oof