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

Server not recieving RemoteEvent?

Asked by 4 years ago
Edited 4 years ago

So I've been trying to make a knockoff of Arcane Adventures using magic scripts I've ran across via sites such as this website and devforums and mashing them all together. The one problem I ran into recently is that my localscript fires a message when Q is pressed, but the server never receives the message and does not create the magic. Could anyone help me figure out what I'm doing wrong?

Local Script

local debris = game:GetService("Debris")
local cas = game:GetService("ContextActionService")

local fireball = "Fireball"

local tool = script.Parent

local fireballEvent = tool:WaitForChild("FireballEvent")

local function handleAction(actionName, inputState, inputObject)
    if actionName == fireball and inputState == Enum.UserInputState.Begin then
        fireballEvent:FireServer()
        print("Fired")
    end
end

--only works if tool is equipped
tool.Equipped:Connect(function()
    cas:BindAction()
end)

tool.Unequipped:Connect(function()
    cas:UnbindAction(fireball)
end)

Server Script

local debris = game:GetService("Debris")

local fireball = "Fireball"

local tool = script.Parent
local anime = script:WaitForChild("Animation")

local speed = 25
local circlesize = Vector3.new(4, 4, .1)
local enabled = true

local fireballEvent = tool:WaitForChild("FireballEvent")

local function onFireballEvent(player)
    local character = player.CharacterAdded:Wait()
    local hrt = character:FindFirstChild("HumanoidRootPart")
    print("Recieved")

    if not enabled then return end -- check to see if magic has already been cast
    enabled = false


    --play animation
    local loadAnim = character.Humanoid:LoadAnimation(anime) 
    loadAnim:Play()

    --magic circle
    local c = Instance.new("Part", character)
    c.CFrame = hrt.CFrame * CFrame.new(0, 0, -3)
    c.TopSurface = "Smooth"
    c.BottomSurface = "Smooth"
    c.Size = Vector3.new(.1, .1, .1)
    c.Transparency = (1)
    c.CanCollide = false
    c.Anchored = true

    local d = Instance.new("Decal", c) --magic circle image
    d.Face = "Front"
    d.Texture = "http://www.roblox.com/asset/?id=2106074393"
    local d2 = Instance.new("Decal", c)
    d2.Face = "Back"
    d2.Texture = "http://www.roblox.com/asset/?id=2106074393"

    local light = Instance.new("PointLight", c)
    light.Color = Color3.new(255, 170, 0)

    local attachment = Instance.new("Attachment", c)

    local particle = Instance.new("ParticleEmitter", attachment)
    particle.Color = ColorSequence.new(Color3.fromRGB(255, 68, 5))
    particle.LightEmission = 1
    particle.LightInfluence = 0
    local sizesequence = {
        NumberSequenceKeypoint.new(0, 0);
        NumberSequenceKeypoint.new(.75, 6);
        NumberSequenceKeypoint.new(1, 0);
    }
    particle.Size = NumberSequence.new(sizesequence)
    particle.Texture = "rbxassetid://1454292685"
    particle.Transparency = NumberSequence.new(.8)
    particle.EmissionDirection = "Front"
    particle.Enabled = false
    particle.Lifetime = NumberRange.new(.8, .8)
    particle.Speed = NumberRange.new(0, 0)
    particle:Emit() 

    --grow magic circle
    local csize = c.Size
    character.HumanoidRootPart.Anchored = true --make sure no one goes anywhere

    for i = 1, 7 do
        c.Size = csize:Lerp(circlesize, i/7)
        wait(0.08)
    end
    loadAnim:AdjustSpeed(0)

    --magic attack
    local p = Instance.new("Part", workspace)
    p.CFrame = c.CFrame
    p.TopSurface = "Smooth" 
    p.BottomSurface = "Smooth" 
    p.Shape = Enum.PartType.Ball 
    p.Size = Vector3.new(2, 2, 2) 
    p.Transparency = (1)
    p.CanCollide = false
    p.BrickColor = BrickColor.new("Really red")

    local ParticleEffect = Instance.new("ParticleEmitter", p) --make the attack beautiful
    ParticleEffect.Size = NumberSequence.new(3)
    ParticleEffect.Transparency = NumberSequence.new(0.8)
    ParticleEffect.LightEmission = 0.3
    ParticleEffect.Rate = 2860
    ParticleEffect.Acceleration = Vector3.new(0,0,0)
    ParticleEffect.Lifetime = NumberRange.new(0.2)
    ParticleEffect.Speed = NumberRange.new(2)
    ParticleEffect.Rotation = NumberRange.new(-360,360)
    ParticleEffect.RotSpeed = NumberRange.new(-360,360)
    ParticleEffect.Texture = "http://www.roblox.com/asset/?id=318675800"

    local antigrav = Instance.new("BodyForce", p)
    antigrav.Force = Vector3.new(0, workspace.Gravity * p:GetMass(), 0)
    local bf = Instance.new("BodyForce", p)
    bf.Force = c.CFrame.lookVector * speed
    debris:AddItem(p, 7)

    --shrink circle
    character.HumanoidRootPart.Anchored = false
    for i = 1, 3 do
        c.Size = circlesize:Lerp(csize, i/3)
        wait(0.08)
    end
    c:Destroy()
    loadAnim:Stop()
    wait(2)
    enabled = true
end

fireballEvent.OnServerEvent:connect(onFireballEvent)
0
you mean remoteevent, correct? theking48989987 2147 — 4y
0
Yes, thank you. The_EvilTriangle 2 — 4y

1 answer

Log in to vote
0
Answered by
megukoo 877 Moderation Voter
4 years ago

local character = player.CharacterAdded:Wait() in your server script may be the issue. The character may already be loaded, and this line will keep waiting for it to spawn again.

Try changing this to local character = player.Character or player.CharacterAdded:Wait().

0
Thank you. This fixed it! The_EvilTriangle 2 — 4y
Ad

Answer this question