well. my problem its i dont know how to create objects around player.
I wan create something similar to aoe attack. but with effects like rocks spawning.
well. my problem its i dont know how to create objects around player.
I wan create something similar to aoe attack. but with effects like rocks spawning.
You would get the players position.
so the players position would be:
local Pos = Player.Character.HumanoidRootPart.Position
then to create a object you can use instance.new
so for a part that would be:
local Rock = instance.new(“Part”)
so now we have the Players position and started creating the part. Now you have to put the part into the game.
Rock.Parent = game.Workspace (Puts it into the world)
Rock.Position = Pos (Makes the rock appear where the character is)
These guys will be your best friend
https://developer.roblox.com/en-us/api-reference/datatype/CFrame
ik about it. but can i get any example to do it in my case.
You can always make it at the players position but if you wanted to offset it to a certain spot near the character it would not work
lemme get receration of what i want. it would be fast
true but I figured if they do not know how to create parts they might struggle with CFrame
was trying to keep it simple to start with
Okay. If you want a part in front of the player, do;
wait(10)
local part = Instance.new("Part", game.Workspace)
local newpart = Instance.new("Part", game.Workspace)
-- Creates a part and sets the Parent to the workspace so we can see it.
local HumanoidRoot = game.Players.MyPlayer.Character:WaitForChild("HumanoidRootPart")
-- This is an example, But you need to grab a player and put the PlayerName where it says ("MyPlayer").
part.Position = HumanoidRoot.Position + (HumanoidRoot.CFrame.lookVector * 20)
-- Get the direction the player is looking at, Get the Vector3 Position 20 studs in front of the character, Place the part.
newpart.Position = HumanoidRoot.Position + (((HumanoidRoot.CFrame.lookVector * 20) + (HumanoidRoot.CFrame.rightVector * 20))/1.5)
-- Math Involved to make it this location around the player.
part.Anchored = true
newpart.Anchored = true
-- Anchor the parts to see results.
What I’m doing here is adding the rightVector, and the lookVector, to get what is in between. Then dividing so it has the same effect as a circle. You can do the same in all directions. If you want a leftVector just do negative of the rightVector, if you want a backVector, do a negative of the lookVector.
If you want the full script,
wait(10)
local part = Instance.new("Part", game.Workspace)
local newpart = Instance.new("Part", game.Workspace)
local newpart2 = Instance.new("Part", game.Workspace)
local newpart3 = Instance.new("Part", game.Workspace)
local newpart4 = Instance.new("Part", game.Workspace)
local newpart5 = Instance.new("Part", game.Workspace)
local newpart6 = Instance.new("Part", game.Workspace)
local newpart7 = Instance.new("Part", game.Workspace)
local distance = 10
local HumanoidRoot = game.Players.MyPlayer.Character:WaitForChild("HumanoidRootPart")
local randomval1 = math.random(1, 360)
local randomval2 = math.random(1, 360)
local randomval3 = math.random(1, 360)
part.Position = HumanoidRoot.Position + (HumanoidRoot.CFrame.lookVector * distance)
newpart.Position = HumanoidRoot.Position + (((HumanoidRoot.CFrame.lookVector * distance) + (HumanoidRoot.CFrame.rightVector * distance))/1.5)
newpart2.Position = HumanoidRoot.Position + (HumanoidRoot.CFrame.rightVector * distance)
newpart3.Position = HumanoidRoot.Position + (((-HumanoidRoot.CFrame.lookVector * distance) + (HumanoidRoot.CFrame.rightVector * distance))/1.5)
newpart4.Position = HumanoidRoot.Position + (-HumanoidRoot.CFrame.lookVector * distance)
newpart5.Position = HumanoidRoot.Position + (((-HumanoidRoot.CFrame.lookVector * distance) + (-HumanoidRoot.CFrame.rightVector * distance))/1.5)
newpart6.Position = HumanoidRoot.Position + (-HumanoidRoot.CFrame.rightVector * distance)
newpart7.Position = HumanoidRoot.Position + (((HumanoidRoot.CFrame.lookVector * distance) + (-HumanoidRoot.CFrame.rightVector * distance))/1.5)
part.Anchored = true
newpart.Anchored = true
newpart2.Anchored = true
newpart3.Anchored = true
newpart4.Anchored = true
newpart5.Anchored = true
newpart6.Anchored = true
newpart7.Anchored = true
spawn(function()
while wait() do
randomval1 = math.random(1, 360)
randomval2 = math.random(1, 360)
randomval2 = math.random(1, 360)
end
end)
part.Orientation = Vector3.new(randomval1, randomval2, randomval3)
newpart.Orientation = Vector3.new(randomval1, randomval2, randomval3)
wait(.1)
newpart2.Orientation = Vector3.new(randomval1, randomval2, randomval3)
wait(.1)
newpart3.Orientation = Vector3.new(randomval1, randomval2, randomval3)
wait(.1)
newpart4.Orientation = Vector3.new(randomval1, randomval2, randomval3)
wait(.1)
newpart5.Orientation = Vector3.new(randomval1, randomval2, randomval3)
wait(.1)
newpart6.Orientation = Vector3.new(randomval1, randomval2, randomval3)
wait(.1)
newpart7.Orientation = Vector3.new(randomval1, randomval2, randomval3)
It’s really messy so I don’t recommend doing it this way. I prefer using tables.
god this script so messy. well i will try figure out it by myself. thanks for helping
This is a clear solution. I can do it in a more simple way but It doesn’t seem you are ready for it. It is a very messy script .
When creating magic attacks and things of the sorts, you have to specify the location of parts, Magic scripts are normally messy.
local yOffset = -2 --How far you want your parts to go down below the HMRP
function Part() -- Function to instantiate your part for each limb
local prt = Instance.new("Part",workspace)
prt.Anchored = true
prt.CanCollide = false
return prt
end
local total = 8 -->> Such as there are 8 limbs in this post
local radius = 10
for i=1,total do
local angle = (math.pi*2/total) * i -- There are 360 degrees in a circle or pi*2 radians
local x = radius * math.cos(angle)
local y = radius * math.sin(angle)
local part = Part()
part.CFrame = HMRP.CFrame * CFrame.new(x, yOffset, y)
part.CFrame = CFrame.new(part.CFrame.p, HMRP.p)
end
Here is a quick script which uses trigonometry to create a series of parts which circles your player
Im no so stupid or smth. if im asking to do such a thing with math problems and more it means im trying do it.
Never did I call you stupid, when helping others I want them to learn from it. Not to copy/paste. People don’t normally learn much from copy/pasting.
It seems that you haven’t created a version of the script prior either.
I never was working with such things as cos, sin in scripts. so im trying learn more math thigns to do effects.
Oh heres example of my last script
Works Fine. Thanks. Im gonna modify it so yeah.
how do you get it to make the parts rotate a certain way like this
local RayCast = Ray.new(HRP.CFrame.p,Vector3.new(0,-1000,0))
local PosInfo = TweenInfo.new(.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local hit,position = workspace:FindPartOnRayWithIgnoreList(RayCast,{Character,visual})
if hit ~= nil then
for i = 1,10 do
local rayOrigin = HRP.Position
local rayDirection = Vector3.new(0, -100, 0)
local Info = TweenInfo.new(.3,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local Goal = {Position = Vector3.new(math.sin(360 * i) * 8, 0, math.cos(360 * i) * 8) + position or Vector3.new(0, -1000, 0)}
local Block = Instance.new('Part')
Block.CanCollide = false
Block.Size = Vector3.new(5,5,5)
Block.Rotation = Vector3.new(math.random(-360, 360), math.random(-360, 360), math.random(-360, 360))
Block.Position = HRP.Position+Vector3.new(0,-3,0)
Block.Parent = visual
local positionToTweenTheEpicRockToo = Vector3.new(math.sin(360 * i) * 8, 0, math.cos(360 * i) * 8) + position or Vector3.new(0, -1000, 0)
local raycastParams = RaycastParams.new()
local result = workspace:Raycast(positionToTweenTheEpicRockToo + Vector3.new(0, 5, 0), Vector3.new(0, -10, 0), raycastParams)
if (result) then
Block.BrickColor = result.Instance.BrickColor
Block.Material = result.Material
end
local Info2 = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local RockTween = {Position = Vector3.new(math.sin(360 * i) * 8, 0, math.cos(360 * i) * 8) + position or Vector3.new(0, -1000, 0)}
game.Debris:AddItem(Block,after)
local yes = TweenService:Create(Block,Info,Goal)
yes:Play()
--[[
game.Workspace.Sounds.explosion_damage1:Play()
FX.Parent = workspace.Visuals
FX.CFrame = HRP.CFrame*CFrame.new(0,-2.5,0)
wait(.6)
FX:Destroy()
]]
end
end
What should I put instead of “visual”?
anything really, aslong as it is in the workspace