I have this script which makes the tool increase the amount of stat it gives when activated if player is in the zone (An invisible cube i made) and has the enough stats required. I tought i could use :GetTouchingParts() but it hink i used it wrong.
if hrp:GetTouchingParts(crystal.Zone) then
if stat >= crystal.Req.Value then
stat = stat + (multi * crystal.Multi.Value)
print("CRYSTAL")
debounce = true
wait(1)
debounce = false
elseif stat < crystal.Req.Value then
stat = stat + multi
end
end
Oh. Okay thanks for the info. BTW i will have more than 1 crystal so should it be ok if i use the same technique for all in one script or should i have a number value in backpack that would change dependinging on the crystal if has stat required?
Okay i tried editing the script and i couldnt get it to work. It only prints the “IT DOESNT WORK” twice
function test ()
for i, v in hrp:GetTouchingParts() do
if v == crystal.Zone then
print("IT WORKS")
if v == redcrystal then
print("RED CRYSTAL WORKS TOO")
end
else
print("IT DOESNT WORK")
end
end
end
Ok but it has to connect with player. I made the stats like this. game.Players.Stats.(4 number values). And i have the script in the tool which gives the player one of the 4 stats. Theres a multiplier player can buy and a multiplier player can have from zones if they meet the required stat.
Hrp is humanoid root part.
function test ()
for i, v in pairs(crystal.zone:GetPartsInPart()) do
if v == hrp then
print("IT WORKS")
end
if v == redcrystal then
print("RED CRYSTAL WORKS TOO")
else
print("IT DOESNT WORK")
end
end
end
function test ()
for i, v in pairs(crystal.zone:GetPartsInPart()) do
if v == hrp then
print("IT WORKS")
end
if v == redcrystal then
print("RED CRYSTAL WORKS TOO")
else
print("IT DOESNT WORK")
end
end
end
function test ()
for i, v in pairs(crystal.Zone:GetTouchingParts()) do
if v == hrp then
print("IT WORKS")
end
if v == redcrystal then
print("RED CRYSTAL WORKS TOO")
else
print("IT DOESNT WORK")
end
end
end
Players.Ozhan02.Backpack.test tool.Script:8: attempt to index nil with 'GetPartsInPart' - Server - Script:8
code im using now…
function test ()
for i, v in pairs(WorldRoot:GetPartsInPart(crystal.Zone)) do
if v == hrp then
print("IT WORKS")
end
if v == redcrystal then
print("RED CRYSTAL WORKS TOO")
else
print("IT DOESNT WORK")
end
end
end
Its in a tool btw with a tool.Activated:Connect(test)
Requires a handle and ManualActivationRequired are off
I watched a video about doing the same thing and the guy uses a (hit) parameter where he uses :GetPlayerFromCharacter(hit.Parent) ill try that and come back