game.Players.PlayerAdded:connect(function(plr) if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,281158690) then script.Parent.Touched:connect(onTouched) function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then game:GetService("TeleportService"):Teleport(284507186, player) end end end end)
I'm actually not quite too sure how to describe it. I'm just trying to make a script that will check the user's inventory for a certain badge before teleporting them to another place.
Here's the developer console log:
15:33:11 -- Attempt to connect failed: Passed value is not a function 15:33:11 --Script 'Workspace.Part.Script', Line 6 15:33:11 -- Stack End
You can't call a function that's defined LATER in the script!
function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) --Get player from character if player and game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 281158690) then --Check if he has the asset here game:GetService("TeleportService"):Teleport(284507186, player) end --End conditional statement end --End function definition script.Parent.Touched:connect(onTouched)