#need some help with my code
1 messages · Page 1 of 1 (latest)
This can easily be achieved my manipulating the pivot of the part
the central part?
the code creates seperate parts and has them orbit around a centre, they arent under one part
why not just set everyones pivot the the center OR make a model and set this pivot to center
if i set all the parts pivot to the centre, the radius no longer becomes dynamic but ill try the model one
It would look something like this
Make sure the center part is the PrimaryPart of the model
when i try to rotate the parts they are put back into their original position because of how their rotation is calculated
Why is the Model one not working
when you rotate the parts in the model, it moves them but the calculation for rotation wouldnt change so it just puts them back to where they would be
what the hell are you calculating
local phase = math.random() * 2 * math.pi
-- Animation variables
local angle = 0 -- Current angle in radians
local Time = 0
-- Start animation loop using Heartbeat
local function Destroy()
while part.Transparency < 1 do
part.Transparency += 0.01
task.wait(0.001)
end
part:Destroy()
end
task.spawn(function()
while part and part.Parent do
local dt = RunService.Heartbeat:Wait()
-- Update angle (convert degrees/sec to radians/sec)
angle += math.rad(rotationSpeed) * dt
Time += dt
-- Calculate new position
local x = math.cos(angle) * radius
local z = math.sin(angle) * radius
local y = origin.Y + math.sin(tick() * bobFrequency + phase) * bobAmplitude + (Time*60)
radius = (math.sin(Time * 0.25 * math.pi * 2 ) * 7) + 7 -- Distance from the center
-- Apply position
part.Position = Vector3.new(origin.X + x, y, origin.Z + z)
end
end)
local targetSize = Vector3.new(73.489, 17.936, 73.489) * 1.25
local SizeTweenInfo = TweenInfo.new(1.25,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)
local sizeTween = TweenService:Create(part,SizeTweenInfo,{Size = targetSize})
sizeTween:Play()
it basically is tracking the co-ordinates around a circle using radians to find where it would be
🥀🥀🥀🥀
am i cooked?
aint no way anyone able to read that
kinda
no ones gonna look through that script cause its so ahh to read
but we can find a diffrent solution which is also more readable and maybe easier for you
I just dont understand what you are trying to do
i was thinking that if i can change the starting orientation, that it would have the same effect
** You are now Level 2! **
since its all rotating at the same rate rn, if i change the point at which it starts to go out, then it might work
this is how I understood it you want 2 rotation thingies
sort of ye
but a model would legit do that or not
na
the tweening is only for the size
or like tween but
bro
I dont even understand where you would use that
like watafak
are you even doing
basically a tornado
i cant adjust the radius if i use a model
then use pivot there you can
This is the simpliest way of fixing ur problem
hang on im onto something
you could do that cause PrimaryPart.Position - OtherPart.Position = Radius
alr
omg it worked lol
thats so dumb
local x = math.cos(angle+xOffset) * radius
xOffset += 0.05
that was literally all i had to do
ikr
I dont want anything todo with that
I learnt 3h yesterday about Type Checker
the hell is a typechecker
--!strict
--[[
======================
==== END USER API ====
======================
Credits: zyos73
]]--
export type API = {
DEBUG: boolean,
_VERSION: string
}
local _API : API = {
DEBUG = false,
_VERSION = "0.1"
}
local API = setmetatable({}, {
__index = _API,
__newindex = function(_, input, newvalue)
if input:match("^_") then
error(`\n{input} is read-only`)
return
end
if typeof(rawget((_API :: any), input)) ~= typeof(newvalue) then
error(`\n{input} assigned wrong type: \nexpected: {typeof(rawget((_API :: any), input))}, \ngot: {typeof(newvalue)}`)
return
end
(_API :: any)[input] = newvalue
end
})
return API
just to create this
mate im lost on the first line
--!strict activates the like strict mode for type checker
is this just to check for like data type values
_API has the type API and DEBUG is supposed to be a boolean so it underlines it orange cause its a number that there is something wrong yk
oh i get it
so it just stops people putting the wrong type of data like a integer for a boolean value
basicly
also if you use auto completion from a custom module itll show you what type it needs
might learn that if i have the time
ye its pretty intresting
but not really needed if you have basic stuff
if you dont use --!strict its just not gonna show you that its the wrong type
i hate it when code does stuff like that
cant it just realise that i want it to show me
Lua has no constants thats why this exists probably
local number : number = 3
number = "x"
its not wrong but if you expect the number to be a number and like make math with it even tho its a string its gonna crash and thats like the main reason to learn it
heres an example of the auto complete btw
ive done python and is it not the same in lua where you can just go int(variable) and make sure its an integer
if that works then why cant you just do that instead of learning the type check
** You are now Level 3! **
this bot i swear
that was an example if you expect a ValueBase and you want to change the Value but its not a ValueBase thats gonna also crash
local Bool : ValueBase = 3
Bool.Value = true --error
the strict type checker is gonna tell you "yo thats the wrong type here"
so it will just do a warning and then move on instead of an outright crash
no itll just show you
so it will still crash
orange thingy
oh
yes it will crash
so you dont even have to run it
yes
and itll detect
ye
ok thats cool
if you want a value to be a changeable type you can give it local newVar : any = 3
so then you can make that into a string later
where could you use this
local API = setmetatable({}, {
__index = _API,
__newindex = function(_, input, newvalue)
if input:match("^_") then
error(`\n{input} is read-only`)
return
end
if typeof(rawget((_API :: any), input)) ~= typeof(newvalue) then
error(`\n{input} assigned wrong type: \nexpected: {typeof(rawget((_API :: any), input))}, \ngot: {typeof(newvalue)}`)
return
end
(_API :: any)[input] = newvalue
end
})
return API
Here
I know 100% that _API is the right type thats why im forcing it to be any
wdym
if i wanted to use a Instance thats to like make a new part so i can spawn new things into the game. so i can use that to make new things. what exactly can you do with checking the data type of something.
surely you should already know what type it is
or am i just being thick
local function resizePart(part : BasePart) --makes sure its a BasePart
part.Size = Vector3.new(5,5,5)
end
resizePart(game.Workspace.Part)
do you mean something like this
no i mean when to you the checking this as a whole
like why would i need to check it if i know what im putting in
Lets say you have 1000 lines of code and you want to call a function but you forgot if it needs a string or a number with type checker youll instantly know what you need cause it gets orange
so it basically is a quick way to check variable types
thats pretty cool
i wont use it because my code rn is like 200 lines max
but it sounds helpful
i got like 4 months on it and i look at the pro scripting channel and it looks like ancient aztec
i swear i saw someone summoning a demon in that code
anyway thanks for the help
and telling me about the type check
FR THO THESE PEOPLE ARE CRAZY