I have a semi-longish script for an experiment. A local one and a server one. I'm testing one local one so I wouldn't have to send all the other locals because they are almost the exact same.
I'll show you what is wrong with the script(s).
LocalScript:
local ReplicatedStorage = game.ReplicatedStorage
local Event = ReplicatedStorage.Xlockevent
local Pos = script.Parent.Parent.Xpos.Text -- This might be the part that you should focus on.... It does look innocent, though.
local enabled = false
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if enabled == false then
enabled = true
script.Parent.Style = "RobloxRoundDefaultButton"
Event:FireServer(enabled, Pos)
elseif enabled == true then
enabled = false
script.Parent.Style = "RobloxRoundButton"
Event:FireServer(enabled, Pos)
end
end)
ServerScript (Go to line 20!)
local ReplicatedStorage = game.ReplicatedStorage
local ServerStorage = game.ServerStorage
local brick = ServerStorage.SpawnBrick
local ypos = false
local yposn = nil
local xpos = false
local xposn = nil
local zpos = false
local zposn = nil
local on = true
local ox = 0
local oy = 0
local oz = 0
ReplicatedStorage.Ylockevent.OnServerEvent:Connect(function(plr, enabled, Pos)
print("Yfired")
if enabled == true then
ypos = true
yposn = Pos
print(Pos) -- When I tried to print it, it printed "Enter Y position" in the Text Box, instead of 2 the that I entered when I was testing (It was "Enter Y position" and then I changed it to 2 when I was testing(entering 2 in the text box)).
end
end)
ReplicatedStorage.Xlockevent.OnServerEvent:Connect(function(plr, enabled, Pos)
print(enabled)
if enabled == true then
xpos = true
xposn = Pos
end
end)
ReplicatedStorage.Zlockevent.OnServerEvent:Connect(function(plr, enabled, Pos)
if enabled == true then
zpos = true
zposn = Pos
end
end)
ReplicatedStorage.BuildEvent.OnServerEvent:Connect(function(plr, MouseHit)
if on ~= true then return end
local cbrick = brick:Clone()
cbrick.Parent = workspace
print(xpos)
print(ypos)
print(zpos)
-- The rest is kinda.. Sloppy... Don't have to read this word by word; it has nothing to do with it. However it's glitched because of that value not changing.
if ypos == true and xpos ~= true and zpos ~= true then -- Y only
cbrick.CFrame = CFrame.new(MouseHit.X, yposn, MouseHit.Z)
elseif xpos == true and ypos ~= true and zpos ~= true then -- X position only
cbrick.CFrame = CFrame.new(xposn, MouseHit.Y, MouseHit.Z)
elseif zpos == true and ypos ~= true and xpos ~= true then
cbrick.CFrame = CFrame.new(MouseHit.X, MouseHit.Y, zposn) -- Z position only
elseif zpos == true and ypos == true and xpos ~= true then -- Z and Y positions
cbrick.CFrame = CFrame.new(MouseHit.X, yposn, zposn)
elseif zpos == true and ypos == true and xpos == true then -- All positions
cbrick.CFrame = CFrame.new(xposn, ypos, zposn)
elseif zpos == true and ypos ~= true and xpos == true then -- X and Z positions
cbrick.CFrame = CFrame.new(xposn, MouseHit.Y, zposn)
elseif zpos ~= true and ypos == true and xpos == true then -- Y and X positions
cbrick.CFrame = CFrame.new(xposn, yposn, zposn)
else -- Anything else
cbrick.CFrame = MouseHit
end
cbrick.Orientation = Vector3.new(ox, oy, oz)
end)

1 comment
Plus, there are no errors