I am very confused by RemoteEvents and RemoteFunctions. I understand how they work but not how to put them to use in regards to what I need to do.

In a project I'm working on, there are local scripts that make an instance and clone things into it that cause damage, add effects, etc. It still works with FilteringEnabled on, but other players cannot see any part of it except the animation.

Could I please get some help with turning this into a RemoteEvent or RemoteFunction?

Thanks for reading.

Script (I know that onKeyDown is deprecated, I will change that later):

local Player = game.Players.LocalPlayer 
local mouse = Player:GetMouse() 
local lastUse = 0;
local char = Player.Character or Player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
Player.CharacterAdded:connect(function(character)
        char = character
    hum = char:WaitForChild("Humanoid")
end)
if not hum.Parent then
    repeat wait(0.2) until hum.Parent
end

local function onKeyDown(key) 
    local Key = key:lower()
    if key == "z" and tick()-lastUse > 10 and Player.NonSave.SkillUse.Value == 0 and Player.Levelss.Hamon.Value == 1 and Player.Levelss.Energy.Value >=20  then 
	    lastUse = tick(); 
	    Player.NonSave.SkillUse.Value = 1
	    Player.Levelss.Energy.Value = Player.Levelss.Energy.Value - 20
        local x = Instance.new("Part")
        x.BrickColor = BrickColor.new("Gold")
        x.Material = "Neon"
        x.CanCollide = false
        x.Transparency = 0.9
        x.Size = Vector3.new(12,1,12)
        x.TopSurface = "Smooth"
        x.BottomSurface = "Smooth"
        x.Shape = "Block"
        x.Anchored = true
        x.Name = Player.Name
        local fix =  game.ReplicatedStorage.EmergencySkillRemove:Clone()
	    fix.Parent = x
        local m = Instance.new("CylinderMesh")
        m.Scale = Vector3.new(0.8,0.8,0.8)
		m.Parent = x
        local fd = script.fireDamage:clone()
        fd.Parent = x
        local DAMAGE = script.Damage:clone()
        DAMAGE.Value = DAMAGE.Value + Player.Levelss.SkillDamage.Value
        DAMAGE.Parent = fd
       
        local ef = script.ef:Clone()
			ef.Parent = char["RightFoot"]
			local ef3 = script.ef:Clone()
			ef3.Parent = char["RightUpperLeg"]
			local ef4 = script.ef:Clone()
			ef4.Parent = char["RightLowerLeg"]
			








         local animTrack = hum:LoadAnimation(script.Eruption)
			animTrack:Play()
			wait(1)
			animTrack:Stop()
            


        
        local a = Instance.new("Sound")
        a.SoundId = "http://www.roblox.com/asset/?id=82277505" --76047008
        a.Parent = x
        a.Volume = 1
        a:play()

        
        Player.NonSave.SkillUse.Value = 0

       

        x.CFrame = Player.Character.UpperTorso.CFrame*CFrame.new(0, -2.9 , 0)  * CFrame.fromEulerAnglesXYZ(-2.7,0,0)
        x.Parent = workspace  
        game.Debris:AddItem(x, 5)
        game.Debris:AddItem(ef,5)
        game.Debris:AddItem(ef3,5)
        game.Debris:AddItem(ef4,5)
      
  
        for explode = 1,30 do
		m.Scale = m.Scale + Vector3.new(0.01,0,0.01)
		x.Transparency = x.Transparency - 0.02
		wait(0.0001)
        end
         
        local mist = script.Effect:clone()
        mist.Parent = x


        
    end
end


mouse.KeyDown:connect(onKeyDown)

2 comments

1

Check out the tools tutorial on Roblox wiki. It shows a very simple example of using remote events. http://wiki.roblox.com/index.php?title=Tools#Communicating_between_Script_and_LocalScript

0

Thanks for the comment. Just got to checking this now, I will read up on that wiki ASAP.