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)
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.