generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Works in Studio but not in a Server? *RemoteFunction*

Previous Thread :: Next Thread 
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 12:28 PM
Local Script:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local Torso = character:FindFirstChild("Torso")
local StarterGear = player:WaitForChild("StarterGear")
local Backpack = player:WaitForChild("Backpack")
local ItemName = script.Parent.Parent:WaitForChild("Item")
local Remote = character:WaitForChild("WeaponDrop")
local RemoteA = Remote:WaitForChild("DropFunction")
print('Assets loaded')

repeat wait() until ItemName.Value ~= "None" -- Waits until It's the value of a real Weapon
print('Weapon selected!')

script.Parent.MouseButton1Click:connect(function()
print('Clicked!')
RemoteA:InvokeServer()
print('Fired!')
end)


It only prints up to Clicked. But the weird thing is that in the regular script, it still prints Received.

Regular Script:

local RemoteA = script:WaitForChild("DropFunction")
print('Test')
RemoteA.OnServerInvoke = function(player)
print('Received!')



Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 12:37 PM
;-;



Report Abuse
NetworkReplicated is not online. NetworkReplicated
Joined: 22 Dec 2010
Total Posts: 330
22 Mar 2016 12:53 PM
@above unhelpful

@op

try return true at the end of recieved, or just returning anything. may work.
Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 01:01 PM
wtf that worked!
idek how!



Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 01:02 PM
can you explain to me what that does?



Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
22 Mar 2016 01:07 PM
You should use remote events and store them in replicated storage. I got rid of the stuff that wasn't necessary to the events.

--server script

local RemoteA = game.ReplicatedStorage:WaitForChild("DropFunction")

RemoteA.OnServerEvent:connect(function(plr)
print("Recieved")
end)

--local script

local RemoteA = game.ReplicatedStorage:WaitForChild("DropFunction")
local ItemName = script.Parent.Parent:WaitForChild("Item")

repeat wait() until ItemName.Value ~= "None"

script.Parent.MouseButton1Click:connect(function()
RemoteA:FireServer()
end)
Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 01:07 PM
please



Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 01:10 PM
Why ReplicatedStorage?



Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 01:12 PM
Shouldn't I use ServerStorage, because I don't really want the client messing with it.



Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
22 Mar 2016 01:13 PM
Your game should be filtering enabled anyways. Nothing would replicate if the client tried messing with anything.

You should use replicatedStorage so the server and the clients can easily access the remote events.
Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 01:14 PM
@First guy who helped me, Return true doesn't work for this.

Regular:

-- RemoteEvent to drop the weapon
local RemoteA = script:WaitForChild("DropFunction")
print('Test')
RemoteA.OnServerInvoke = function(player)
print('Received!')
-- Loading Assets --
local character = player.Character or player.CharacterAdded:wait()
local PlayerGui = player:WaitForChild("PlayerGui")
local Torso = character:FindFirstChild("Torso")
local StarterGear = player:WaitForChild("StarterGear")
local Backpack = player:WaitForChild("Backpack")
-- Loads until here
local MainGui = PlayerGui:WaitForChild("Inventory")
local ItemName = MainGui.Options:WaitForChild("Item")
repeat wait() until ItemName.Value ~= "None" -- Waits until a Weapon has actually been equipped
local StorageWep = game.ServerStorage:WaitForChild(ItemName.Value)
local RealWep = StarterGear:FindFirstChild(ItemName.Value)
local Amnt = RealWep:WaitForChild("Amount")
local ItemScroll = MainGui:WaitForChild("ItemScroll")
local ItemCheck = ItemScroll:WaitForChild("ItemCheck")
local ItemHolder = ItemScroll:WaitForChild("ItemHolder")
local ItemOrganize = ItemScroll:WaitForChild("Organizer")
local ItemInfo = ItemHolder:FindFirstChild(ItemName.Value)
-- Asset Loaded

if Amnt.Value > 1 then -- If more than 1 of the Item
local StorageWep = StorageWep:Clone() -- Clones Weapon
for _,v in pairs(StorageWep:GetChildren()) do
if not v:IsA("Part") then
v:Destroy()
end
end
StorageWep.Parent = workspace
for _,v in pairs(StorageWep:GetChildren()) do
if v:IsA("Part") then
v.CFrame = Torso.CFrame*CFrame.new(0,0,-5)
end
end
Amnt.Value = Amnt.Value - 1

else -- If only 1 of the Item
if character:FindFirstChild(ItemName.Value) or Backpack:FindFirstChild(ItemName.Value) then -- If already in use
print('Please Unequip to Drop!')
else -- If the 1 Item is not equipped
local StorageWep = StorageWep:Clone() -- Clones Weapon
for _,v in pairs(StorageWep:GetChildren()) do
if not v:IsA("Part") then
v:Destroy()
end
end
StorageWep.Parent = workspace
for _,v in pairs(StorageWep:GetChildren()) do
if v:IsA("Part") then
v.CFrame = Torso.CFrame*CFrame.new(0,0,-5)
end
end
RealWep:Destroy()
ItemInfo:Destroy()
MainGui.Options.Visible = false
ItemCheck.Value = false
ItemOrganize.Disabled = false
end
end
return true
end


Local:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local ItemName = script.Parent.Parent:WaitForChild("Item")
local Remote = character:WaitForChild("WeaponDrop")
local RemoteA = Remote:WaitForChild("DropFunction")
print('Assets loaded')

repeat wait() until ItemName.Value ~= "None" -- Waits until It's the value of a real Weapon
print('Weapon selected!')

script.Parent.MouseButton1Click:connect(function()
print('Clicked!')
RemoteA:InvokeServer()
print('Fired!')
end)


Also Tick I need player/character and remote because they Regular Script is located in the character.





Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 01:17 PM
Wait so if anything in the ReplicatedStorage is changed from client it won't be changed in the server?



Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
22 Mar 2016 01:18 PM
IF your game is FE. Correct
Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 01:19 PM
Oh ok, thanks. Also can you help fix the script above?



Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
22 Mar 2016 01:24 PM
first of all you need to be using a local script instead of a regular script if you want to modify a gui
Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 01:27 PM
The regular isnt modifying things on the gui. It's just reading it and looking for stuff.
It's suppose to be a weapon dropping script.



Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
22 Mar 2016 01:33 PM
Debug your code. Put prints everywhere and see how far they go.
Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
22 Mar 2016 01:34 PM
Ya that's what I'm doing but I switched to RemoteEvent
Thanks for the help
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image