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

How do I spawn parts at the cursors location?

Asked by 5 years ago
Edited 5 years ago

I'm trying to figure out how to spawn parts at the cursors location but I can't seem to figure it out

I'm using it for this script (for my meteor staff).

I need it to spawn 400 studs above the cursors location.

(this is in a server script inside of a tool btw)

function ability1()

    local heat = script.Parent.Heat
    local smoke1 = script.Parent.Smoke1
    local smoke2 = script.Parent.Smoke2
    local wave = script.Parent.Wave
    local aoedamage = script.Parent.aoedamage
    local rock1 = Instance.new("Part")
    local debounce = false

    rock1.Transparency = 1
    rock1.Size = Vector3.new(0,0,0)
    rock1.Parent = workspace
    rock1.Position = Vector3.new(0,320,0)

    local heatClone = heat:Clone()
    local smoke1Clone = smoke1:Clone()
    local smoke2Clone = smoke2:Clone()
    local waveClone = wave:Clone()
    local aoedamageClone = aoedamage:Clone()

    aoedamageClone.Parent = rock1
    heatClone.Parent = rock1
    smoke1Clone.Parent = rock1
    smoke2Clone.Parent = rock1
    waveClone.Parent = rock1

    aoedamageClone.Disabled = false
    heatClone.Enabled = true
    smoke1Clone.Enabled = true
    smoke2Clone.Enabled = true
    waveClone.Enabled = true

end


local function onActivate()
    ability1()
end

script.Parent.Activated:Connect(onActivate)
0
use offsets User#23365 30 — 5y
0
'use offsets' not detailed enough of an answer LoganboyInCO 150 — 5y

1 answer

Log in to vote
1
Answered by
HaveASip 494 Moderation Voter
5 years ago
Edited 5 years ago

this is example script, and you need to edit it

here is localscript:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse() --get player's mouse
local uis = game:GetService("UserInputService")
local remote = game.ReplicatedStorage.RemoteEvent --your remote event location here
local High = 2 -- this will plus 400 studs to hit position

uis.InputBegan:Connect(function(input) --Starts when player inputed some key
    if input.UserInputType == Enum.UserInputType.MouseButton1 then --checks if player pressed mousebutton1(left click)
        local pos = (mouse.hit.p + Vector3.new(0,High,0)) --gets current mouse hit position
        remote:FireServer(pos) --fires to server current mouse hit position
    end
end)

and here is script:

local Event = game.ReplicatedStorage.RemoteEvent --your remote event location here
local ready = true
local debounceTime = 2 --this is the time that when player can fire again

Event.OnServerEvent:Connect(function(player , pos) --starts when player firing from client
    if ready then
        ready = false
        local part = Instance.new("Part") -- instance part
        part.Parent = workspace --set parent
        part.Size = Vector3.new(3,3,3) --set size
        part.Anchored = true
        part.CanCollide = false
        part.Position = pos  --set position that we fire from client
        wait(debounceTime)
        ready = true
    end
end)

1
I hope you understand HaveASip 494 — 5y
0
I need it to spawn above the cursor tho (400 studs above it), but yeah I understand it :d LoganboyInCO 150 — 5y
Ad

Answer this question