So i want a cube of light to be placed wherever the player has his/her mouse when they press R. I'm not sure what the issue is with the code I made.
Local Script:
local Players = game:GetService("Players") local LocalPlayer = Players.LocalPlayer local Mouse = LocalPlayer:GetMouse() local RepStorage = game:GetService("ReplicatedStorage") local DeletePart = RepStorage.DeletePart local UIS = game:GetService("UserInputService") local part = game.Workspace.deletepart UIS.InputBegan:Connect(function(input) local Hitposition = Mouse.Hit if input.KeyCode == Enum.KeyCode.R then print("R Pressed") if Hitposition == nil then DeletePart:FireServer(Hitposition) end end end)
Server Script:
local RepStorage = game:GetService("ReplicatedStorage") local DeletePart = RepStorage.DeletePart local Cube = game.ServerStorage.LightCube:Clone() local Cooldown = {} DeletePart.OnServerEvent:Connect(function(Player, Position) if Cooldown[Player.name] then return warn(Player.Name.." is on cooldown")end Cooldown[Player.Name] = os.time Cube.Name = string.format("%s part", tostring (Player.name)) Cube.Parent = game.Workspace Cube.CFrame = Position delay(2,function() -- 2 = cooldown time Cooldown[Player.Name] = nil end) end)