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)

3 comments
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
Is the local script the whole script? You made an "onActivate" function but it doesn't look like anything is running that function.
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