Haven’t posted here in a while but here goes nothing.
For staters I’m relatively new with Lua and coding in Roblox in general as I only have experience with VB and a little bit of python so bear with me.
I am trying to create an ability in the form of a tool where it places a premade cube anywhere where the player clicks which would act as a barrier supposedly to trap players inside of it. Here is an image of the cube I made for reference.
After the cube is placed a cooldown is to be displayed and after that the cube is to be destroyed and the player is able to place another.
Now comes the problem. Nothing happens at all when I activate the tool by clicking. Not sure what I am doing wrong. I watched numerous tutorials to figure out what I am doing wrong. I’m also relatively new to using remote events and functions so maybe that might be it. Either way nothing is happening and now error appears in the output window so I have no idea where to go from here. I’ve checked over and over and to my limited knowledge everything seems like it should work but clearly not since nothing is happening.
A few more vital information id like to add:
The Explorer tab - Here you can see where I placed everything:
Local Script:
local tool = script.Parent
local toolname = tool.name
local rs = game:GetService("ReplicatedStorage")
local CubeEvent = rs:WaitForChild("Merlin Attacks"):WaitForChild("Events"):WaitForChild("Cube")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local CooldownEvent = rs:WaitForChild("Merlin Attacks"):WaitForChild("Events"):WaitForChild("Cooldowns")
tool.Activated:Connect(function()
local MousePos = Mouse.Hit.Position
if MousePos == nil then return end
CubeEvent:FireServer(MousePos)
end)
local function CooldownTimer(Cooldown)
for i = Cooldown, 0, -1 do
wait(1)
tool.Name = toolname .. " (Cooldown: " .. i .. ")"
end
tool.Name = toolname
end
CooldownEvent.OnClientEvent:Connect(CooldownTimer)
Server Script:
local Debounce = {}
local Cooldown = 20
local rs = game:GetService("ReplicatedStorage")
local CubeEvent = rs:WaitForChild("Merlin Attacks"):WaitForChild("Events"):WaitForChild("Cube")
local PerfectCube = rs["Merlin Attacks"]["Perfect Cube"]
local CooldownEvent = rs:WaitForChild("Merlin Attacks"):WaitForChild("Events"):WaitForChild("Cooldowns")
local function CreateCube(player,MousePos)
if table.find(Debounce,player.name) ~= nil then
print(player.name " is on cooldown!")
else
print(player.Name .. " created a Perfect Cube.")
local CubeClone = PerfectCube:Clone()
CubeClone.Parent = game.Workspace
CubeClone:SetPrimaryPartCFrame(CFrame.new(MousePos))
table.insert(Debounce,player.name)
CooldownEvent:FireClient(Cooldown)
task.wait(Cooldown)
CubeClone:Destroy()
Debounce[table.find(Debounce,player.name)] = nil
end
end
CubeEvent.OnServerEvent:Connect(CreateCube)
Any help would be appreciated as I continue to try and find the issue.
Edits: I fixed some issues and now my current issue is this error when passing values.
If anyone knows what this error means that would be helpful.
Newest edit: I was able to get the cube to place though its always in the ground now so I’m not sure how to fix that and there is a new error with the server script passing the cooldown value through the
remote function on the client side.
New error:
thank you for all your help