What is the issue?
I am intending to make a placement system, but I get an error
. What solutions have you tried so far?
I tried to search for solutions but I didn’t quite understand them, about “put player as first parameter” or “Clear player argument”
— here I leave the local script of the gui –
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Place = ReplicatedStorage:WaitForChild("Place")
local Structures = ReplicatedStorage:WaitForChild("FolderPost")
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local StructureFrame = script.Parent.StructureFrame
local Char = player.Character or player.CharacterAdded:Wait()
local HumanoidRootPart = Char:WaitForChild("HumanoidRootPart")
local mouse = player:GetMouse()
local yBuildingOffSet = 5
local maxPlacingDistance= 50
local rKeyIsPressed = false
local placingStructure = false
for i, structureButton in pairs(StructureFrame:GetChildren()) do
if structureButton:IsA("TextButton") then
structureButton.MouseButton1Up:Connect(function()
StructureFrame.Visible = false
local yOrientation = 0
local goodToPlace = false
local PlaceStructure
if placingStructure == false then
placingStructure = true
[[--Line 33--]] local ClientStructure = Structures:FindFirstChild(structureButton.Name):Clone()
ClientStructure.BrickColor = BrickColor.new("Slime green")
ClientStructure.Material = "Plastic"
ClientStructure.CanCollide = false
ClientStructure.Parent = game.Workspace
local startingCFrame = CFrame.new(0, -2, -15)
ClientStructure.CFrame = HumanoidRootPart.CFrame:ToWorldSpace(startingCFrame)
RunService.RenderStepped:Connect(function()
local mouseRay = mouse.UnitRay
local castRay = Ray.new(mouseRay.Origin, mouse.Direction * 1000)
local ignoreList = {ClientStructure, Char}
local hit, position = workspace:FindPartOnRayWithIgnoreList(castRay, ignoreList)
if hit and (HumanoidRootPart.Position - ClientStructure.Position).Magnitude < maxPlacingDistance then
goodToPlace = true
ClientStructure.BriclColor = BrickColor.new("Slime green")
else
goodToPlace = false
ClientStructure.BrickColor = BrickColor.new("Earth green")
end
local newAnglesCFrame = CFrame.Angles(0, math.rad(yOrientation), 0)
local NewCFrame = CFrame.new(position.X, position.Y, yBuildingOffSet, position.Z)
ClientStructure.CFrame = NewCFrame * newAnglesCFrame
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.R then
rKeyIsPressed = true
local rotationSpeed = 3
while rKeyIsPressed do
wait()
if placingStructure == true then
yOrientation = yOrientation + rotationSpeed
end
end
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.R then
rKeyIsPressed = false
end
end)
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if placingStructure == true then
if goodToPlace == true then
local StructureCFrame = ClientStructure.CFrame
PlaceStructure = placingStructure:InvokeServer(ClientStructure.Name, StructureFrame)
if PlaceStructure == true then
placingStructure = false
ClientStructure:Destroy()
StructureFrame.Visible = true
end
end
end
end
end)
end
end)
end
end
And it’s server script ScriptService is just make it work