invalid argument #3 (string expected, got Instance) ?
I am using proximity prompt to make the player sit on my car seat and detect who the player is. When I do that using the script.Parent.Touched:Connect(function(hit) it doesn’t detect anyone sitting so I have moved on to detecting straight from the proximity prompt and then storing that value on a string value but when I run my code it gives me the invalid argument #3 (string expected, got Instance) ? Does anyone know how to fix this?
- Hit function Script
local player
local MetersDriven = script.Parent.MetersDriven
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
print("Touched")
player = game.Players:GetPlayerFromCharacter(hit.Parent)
end
end)
while true do
MetersDriven.Value = MetersDriven.Value + script.Parent.Velocity.Magnitude
if MetersDriven.Value > 1609 then
MetersDriven.Value = 0
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + script.Parent.MoneyPM.Value
player.leaderstats.Miles.Value = player.leaderstats.Miles.Value + 1
end
wait(1)
end
- Proxi Script
local playerSeat = script.playerSeat.Value
local MetersDriven = script.Parent.MetersDriven
script.Parent.ProximityPrompt.TriggerEnded:Connect(function(plr)
playerSeat = plr
end)
while true do
MetersDriven.Value = MetersDriven.Value + script.Parent.Velocity.Magnitude
if MetersDriven.Value > 1609 then
MetersDriven.Value = 0
playerSeat.leaderstats.Cash.Value = playerSeat.leaderstats.Cash.Value + script.Parent.MoneyPM.Value
playerSeat.leaderstats.Miles.Value = playerSeat.leaderstats.Miles.Value + 1
end
wait(1)
end
Thanks for the help!