The 'PowerUp' should spawning at the UpperTorso position of the zombie but it will spawning on top of it and when a zombie touches him he goes up but I want that it remain her basic position, demonstration -->
How to fix this?
PowerUp Script:
local RStorageService = game:GetService('ReplicatedStorage') local LightingService = game:GetService('Lighting') local SoundService = game:GetService('SoundService') script.Parent.Touched:Connect(function(h) local player = game:GetService('Players'):GetPlayerFromCharacter(h.Parent) if player then --< My script end end)
Rotation Script:
local c = 0 local a = 0 while wait() do if c < 200 then script.Parent.Orientation = script.Parent.Orientation + Vector3.new(0, 0.4, 0) c = c + 1 a = 0 elseif a < 50 then script.Parent.Orientation = script.Parent.Orientation + Vector3.new(0, -0.8, 0) a = a + .5 else c = 0 end end
PowerUp spawning script:
local position = z.UpperTorso.Position local PUp if z.Zombie:FindFirstChild('PowerUp') ~= nil then PUp = z.Zombie.PowerUp.Value; z.Zombie.PowerUp:Destroy() local PoUp = RStorageService.PowerUp[PUp]:Clone() PoUp.Parent = workspace PoUp.Position = position end
Roblox likes to be stupid when it comes to changing orientations of parts. when a part's position/orientation can't be changed due to another part being in the way, it moves above the other part, Even if Anchored and CanCollide are set to false. However, I know a simple solution. Instead of using that script, use this. It requires no more scripting than you've done.
Set the Powerup's
Anchored
andCanCollide
to false.Insert an object called
BodyAngularVelocity
set the property
Velocity
in BodyAngularVelocity to(0,10,0)
. (or change the second number to something more suitable)Insert another object called
BodyVelocity
. Set this one's Velocity to(0,0,0)
.
If it doesn't work, let me know, I can show you an example as I just tested this.