#I have no idea what the problem is

142 messages · Page 1 of 1 (latest)

minor solar
#
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)
#

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

fossil prawn
#

Always use CFrames when moving objects

#

No Position

minor solar
#

ah

fossil prawn
#

Don't use Position and Orientation

minor solar
#

what

#

then what do I use

fossil prawn
#

CFrame

minor solar
#

hiw

#

what

#

for orientation

#

too?

minor solar
#

but how to use i

#

oh

#

like orientation = cframe.new

winter pathBOT
#

I don't recognise the option ,etc. Use ,texconfig to see the list of options.

fossil prawn
#

When you change Position or Orientation it actually changes the cframe (in the wrong way and everything becomes cursed)

fossil prawn
minor solar
#

what

#

thats the same

#

for position

#

You mean Part.Orientation = CFrame.new(...)

#

??

fossil prawn
minor solar
#

ok

fossil prawn
#

CFrame is not Vector3

minor solar
#

whats the difference

fossil prawn
#

Type error

minor solar
#

between changing

#

orientation

#

and position

#

using cframe

#

give a good example

#

so I can understand

#

better

fossil prawn
#

Idk. When you use position it becomes cursed. You said that "it just bugged out" "and now it's just flying"

minor solar
#

yeah

fossil prawn
#

It's overall a better practice to use CFrames

minor solar
#

so your telling me

#

to change orientation

#

using cframe

#

but you dont know either

#

🤦‍♂️

fossil prawn
#

Cframe it's both position and orientation

#

Is*

minor solar
#

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

fossil prawn
#

It should work on client too

minor solar
#

it knows the part is there

#

yeah

fossil prawn
#

Make sure part is anchored

minor solar
minor solar
minor solar
#

is

#

Size

#

so this part

wall.CFrame = Mouse.Hit.Position + CFrame.new(0, wall.Size.Y / 2, 0)
fossil prawn
minor solar
#

hm?

#

what does that mean

#

i have gotten alot of nil errors

#

but never on a part before

fossil prawn
#

First, just try Wall.CFrame = Mouse.Hit and see what happens

minor solar
#

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

fossil prawn
minor solar
#

size

fossil prawn
#

Show me line 56

minor solar
#

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

fossil prawn
#

Do print(wall) before this line

minor solar
#

but its adding it

#

tot he current

#

ok

quiet cloud
minor solar
#

ah

#

alright

minor solar
#

?

#

@quiet cloud oh

#

it prints nil

#

but it only starts

#

once the part

#

is created

#

????

quiet cloud
#

I just did "CFrame"

minor solar
#

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

uncut valveBOT
#

studio** You are now Level 13! **studio

minor solar
#

i fixed it myself