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

Filtering Enabled spawning lightning at the player's position with a tool?

Asked by
jlpt 0
6 years ago

Im trying to make it so that when the player uses the tool it spawns some lightning bolts but the lightning bolts don't spawn. I've checked with it and it seems that it's the position that's the problem i try to get the position of the player by doing char.Torso.CFrame but it doesn't work for some reason it works normally in studio mode

--Local script in tool

local tool = script.Parent
local plr = game.Players.LocalPlayer
local canUse = true
local rs = game:GetService("ReplicatedStorage")
char = plr.Character
event = rs:WaitForChild("SpawnEntity")

local function onActivate()
    for i = 1,10,1 do
        plr.leaderstats.Mana.Value = plr.leaderstats.Mana.Value - 3
        wait(.5)
        event:FireServer(char.Torso.CFrame,"LightningBolt",game.Workspace)
    end
end

--Script in ServerStorage

local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")
local SpawnEntity = Instance.new("RemoteEvent", RS)

SpawnEntity.Name = "SpawnEntity"

local function SpawnEntityFunction(plr,position,entity,parent)
    print('hi')
    local e = tostring(entity)
    local Entity = SS[e]:Clone()
    Entity.Parent = parent
    Entity.CFrame = position
    local creator = Instance.new("StringValue")
    creator.Parent = Entity
    creator.Name = "Creator"
    creator.Value = plr.Name
end

SpawnEntity.OnServerEvent:Connect(SpawnEntityFunction)

1 answer

Log in to vote
0
Answered by 6 years ago

I think it's because scripts don't run in ServerStorage. I made a test script and tried to run it on ServerStorage but nothing is happening. Try putting your script in ServerScriptService or Workspace. That should work.

0
the script is already in serverscriptstorage and also i have a button that does the same thing and it works it's just the tool that won't work and i checked if the tool actually activated and it did so i have no idea what's going on jlpt 0 — 6y
0
Is the local script the whole script? You made an "onActivate" function but it doesn't look like anything is running that function. User#20279 0 — 6y
0
i did i just forgot to copy that part of the code below and i already said that the activate thing works i checked it using print and plus it works in studio jlpt 0 — 6y
Ad

Answer this question