Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Ive notice that when I have a block it doesnt spawn towards to mouse why?

Asked by 5 years ago
Edited by Gey4Jesus69 5 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

My script is a remote event bound script with one local and another server. I can send information of where the mouse is but after that it just relays the same information over and over again which isn't very helpful. I was wondering if there was any fixes for this? Here's my scripts:

Local script

local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer -- from a LocalScript
local mouse = localPlayer:GetMouse()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local MouseEvent = ReplicatedStorage:FindFirstChild("Mouse")
local Mouseposition = mouse.Hit
local mouseX = mouse.X
local mouseY = mouse.Y

UIS.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.Q then
            if Players.LocalPlayer.Character then
                MouseEvent:FireServer(mouseY)
            end
        end
    end
end)

Server script:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:FindFirstChild("Spells")
local cooldown = "on"
local mouse = ReplicatedStorage:FindFirstChild("Mouse")

local function Recieved(player, mouse)
    if cooldown ~= "off" then
        local torso = player.Character:WaitForChild("HumanoidRootPart")
        local Part = Instance.new("Part")
        Part.Parent = torso
        Part.Position = Vector3.new(0,mouse,0)
        Part.CFrame = torso.CFrame + torso.CFrame.LookVector * 10
        cooldown = "off"
        wait(10)
        cooldown = "on"
        wait(10)
        Part:Destroy()
    end
end

mouse.OnServerEvent:Connect(Recieved)
0
Was wondering why they don't work? voidofdeathfire 148 — 5y
0
There is a variable and a parameter both named "mouse". So the script is getting confused at which one you mean in the function. DeceptiveCaster 3761 — 5y
0
Erm it didnt do anything even if I changed it voidofdeathfire 148 — 5y

Answer this question