|
| 30 Jun 2016 03:20 PM |
| I'm making a point system so if you're driving the car and the car touches it, the points transfer to you. But when the car touches it, the points don't transfer to your leaderstats. Any help? |
|
|
| Report Abuse |
|
|
kools
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 1659 |
|
|
| 30 Jun 2016 03:22 PM |
| We need code posted. A good rule of thumb for this forum is to post errors, unexpected behavior, and code when asking a question about something not working. |
|
|
| Report Abuse |
|
|
|
| 30 Jun 2016 03:28 PM |
| I don't know the script... |
|
|
| Report Abuse |
|
|
kools
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 1659 |
|
|
| 30 Jun 2016 03:35 PM |
| Are you asking how to do this, because the statement: "But when the car touches it, the points don't transfer to your leaderstats" sort of implied that there was already a system in use. Unless you are describing the way you want it to be? |
|
|
| Report Abuse |
|
|
|
| 30 Jun 2016 03:47 PM |
Yes there is one. But the script is only directed to when the player touches it. I need to know how to make it when the car touches it the points transfer to your leaderstats.
Here are the scripts I am using
function onTouched(part) part:Remove() end script.Parent.Touched:connect(onTouched)
Another Script
local ting = 0
function onTouched(hit)
if ting == 0 then ting = 1 check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local user = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = user:findFirstChild("leaderstats")
if stats ~= nil then local points = stats:findFirstChild("Points") points.Value = points.Value +150 wait(1) end
end
ting = 0 end
end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
|
| 30 Jun 2016 04:24 PM |
why two? arent they both for the same thing?
#code while true do end |
|
|
| Report Abuse |
|
|
kools
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 1659 |
|
|
| 30 Jun 2016 04:27 PM |
What we will do is in addition to checking if there is a humanoid, we can also check for a VehicleSeat, and get the occupant property that will supply us with the humanoid.
local ting = 0
function onTouched(hit)
if ting == 0 then ting = 1 humanoid = hit.Parent:FindFirstChild("Humanoid") vehicleseat = hit.Parent:FindFirstChild("VehicleSeat") if vehicleseat then -- Be sure to keep VehicleSeats named VehicleSeat otherwise this would be more complex. humanoid = vehicleseat.Occupant end
if humanoid then
local user = game.Players:GetPlayerFromCharacter(humanoid) local stats = user:findFirstChild("leaderstats")
if stats ~= nil then local points = stats:findFirstChild("Points") points.Value = points.Value +150 wait(1) end
end
ting = 0 end
end |
|
|
| Report Abuse |
|
|