local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local WS = game:GetService("Workspace")
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")
local Event = RS:WaitForChild("Placed")
local PlacedFolder = WS.Placed
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local Name = "WallClone"
local ClonePart = "Wall"
local WallAvailable = false
local wall = workspace:FindFirstChild(Name)
local debounce = false
Mouse.Button1Down:Connect(function()
if wall then
Event:FireServer(wall.CFrame, wall.Orientation, wall.Size, wall.Color, wall.Material)
end
end)
UserInputService.InputBegan:Connect(function(InputObject, gameProcessedEvent)
if InputObject.KeyCode == Enum.KeyCode.R and WallAvailable and not debounce then
wall.Orientation += Vector3.new(0,90,0)
debounce = true
wait(0.1)
debounce = false
elseif InputObject.KeyCode == Enum.KeyCode.X and WallAvailable and not debounce then
wall:Destroy()
debounce = true
wait(0.1)
debounce = false
elseif InputObject.KeyCode == Enum.KeyCode.One and not WallAvailable and not debounce then
local clone = RS.Template:WaitForChild(ClonePart):Clone()
clone.Name = Name
clone.Parent = game.Workspace
WallAvailable = true
debounce = true
wait(0.1)
debounce = false
end
end)
local function Movement()
if Mouse.Target and WallAvailable then
workspace:WaitForChild(Name).Position = Mouse.Hit.Position + Vector3.new(0, workspace:WaitForChild(Name).Size.Y / 2, 0)
Mouse.TargetFilter = wall
end
end
RunService.RenderStepped:Connect(Movement)
#I have no idea what the problem is
142 messages · Page 1 of 1 (latest)
alright so
its something to do with the new part creation
and
the movement function
because it worked before when I made the wall myself
but when I made it in the client
it just bugged out
like
Players.player.PlayerScripts.Client:30: attempt to index nil with 'Orientation'
attempt to index nil with size
until
I put in
workspace:WaitForChild(Name)
and now
its just flying
even if my mouse is still
ah
Don't use Position and Orientation
CFrame
I know for position
but how to use i
oh
like orientation = cframe.new
I don't recognise the option ,etc. Use ,texconfig to see the list of options.
When you change Position or Orientation it actually changes the cframe (in the wrong way and everything becomes cursed)
Part.CFrame = CFrame.new(...)
what
thats the same
for position
You mean Part.Orientation = CFrame.new(...)
??
This obviously will cause error
ok
CFrame is not Vector3
whats the difference
Type error
between changing
orientation
and position
using cframe
give a good example
so I can understand
better
Idk. When you use position it becomes cursed. You said that "it just bugged out" "and now it's just flying"
yeah
It's overall a better practice to use CFrames
what
so your telling me
to change orientation
using cframe
but you dont know either
🤦♂️
Ok this script is a local script
and
it creates a part when you click 1
that only the player can see
and if i made a part using the server
it would work
I think
but
this script is a local script
so it should be working
since its client side
but it seems to not understand Position, orientation
It should work on client too
Make sure part is anchored
but instead of these errors
it already was
the error its giving me
is
Size
so this part
wall.CFrame = Mouse.Hit.Position + CFrame.new(0, wall.Size.Y / 2, 0)
This means that your wall is nil
hm?
what does that mean
i have gotten alot of nil errors
but never on a part before
First, just try Wall.CFrame = Mouse.Hit and see what happens
ok
no but like
the error
its giving
is not about position
or anything
its attempt to index nil with "Size"
Players.player.PlayerScripts.Client:56: attempt to index nil with 'Size' - Client - Client:56
Attempt to index nil with Orientation means you have nil.Orientation in your code
size
Show me line 56
i already did
but here
wall.CFrame = Mouse.Hit.Position + CFrame.new(0, wall.Size.Y / 2, 0)
it divides
the wall size
by 2
Do print(wall) before this line
Also ^
CFrame = CFrame.Angles(math.rad(),0,0)
that instead of /
?
@quiet cloud oh
it prints nil
but it only starts
once the part
is created
????
Because we didn't define CFrame to anything
I just did "CFrame"
wait
let me try something
ok
it works
ah
the problem was
I defined wall at the start
but that definition was only checked once
so what I did
was put the variable
inside
the mouse funciton
and it worked
alr
** You are now Level 13! **
i fixed it myself