Spellbreaker Posted March 9, 2023 Share Posted March 9, 2023 HI. I want to control condition of specific part of vehicle controlled by player. Or another vehicle damaged by player vehicle. Currently my code works only for my character but not for others on my local hosted server. I'm doing for loop over players vehicles and changing state of every part to 100. It seems part.setCondition() has limited access to actual vehicle state. On player side it changes only visual state this script in "server" folder function OnTick() -- if isClient() then return end for playerIndex=0, getNumActivePlayers()-1 do local player = getSpecificPlayer(playerIndex); if player and not player:isDead() then CheckPlayerVehicle(player); end end end function CheckPlayerVehicle(player) local vehicle = player.getVehicle and player:getVehicle() or nil if vehicle == nil or not vehicle:isDriver(player) then return end local partCount = vehicle:getPartCount(); for i=0, partCount-1 do local part = vehicle:getPartByIndex(i); local partHP = part:getCondition(); if (partHP < 100) then part:setCondition(100); partHP = part:getCondition(); print(part:getId() .. " current hp " .. partHP); end end end Events.OnTick.Add(OnTick); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now