Well, I created a script which does what it does but without Filtering Enabled, but when I enable it, as I see, you guys use it... It simply doesn't work! Any help?
SCRIPT:
local GUI_Name = "Blacksmith_GUI" script.Parent.Touched:Connect(function(player) local char = player.Parent local plr = game:GetService("Players"):GetPlayerFromCharacter(char) if char:FindFirstChild("Humanoid") ~= nil then local gui = plr.PlayerGui:WaitForChild(GUI_Name) gui.Enabled = true end end)
And also in that GUI, when you try to purchase an item, this problem appears: ServerStorage is not a valid member of DataModel, here is the script:
local player = game:GetService("Players").LocalPlayer local Storage = game.ServerStorage:FindFirstChild("Storage") local SwordName = "DiamondSword" local Sword = Storage.Swords:WaitForChild(SwordName) local Database = player:WaitForChild("Database") script.Parent.MouseButton1Click:connect(function() if Database.Value_Inv.Stick_Value.Value >= 1 and Database.Value_Inv.Stick_Value.Value >= 2 then script.Parent.AutoButtonColor = false Database.Value_Inv.Stick_Value.Value = Database.Value_Inv.Stick_Value.Value - 1 Database.Value_Inv.Diamond_Value.Value = Database.Value_Inv.Diamond_Value.Value - 2 local copy = Sword:Clone() copy.Parent = player.Backpack local copya = Sword:Clone() copya = player.StarterGear end end)
I'm sorry if my script is bad because I'm still a beginner! Any help will be appriciated! I've tried so many times fixing this and it didn't work, I don't know why is scripting in FE so hard......
PlayerGui
from the server. You'll need a RemoteEvent
for that.ServerStorage
is not a valid member of DataModel
because ServerStorage
is server-side only, it does not exist on the client world. Switch to ReplicatedStorage
to fix. Now, there is a lot bad I am seeing in your code. The first thing being: You're checking the requirements on the client, which gives the client power. They can reduce the requirements. Always have the server do checks. Second thing, you're handling the cloning locally, which will only appear for one player. Handle that on the server.--Server script local ReplicatedStorage = game:GetService("ReplicatedStorage") local cloneTool = ReplicatedStorage:WaitForChild("CloneToolEvent") local checkPrice = ReplicatedStorage:WaitForChild("GetPrice") cloneTool.OnServerEvent:Connect(function(plr, toolName, sticksRequired) if plr.Database.Value_Inv.Stick_Value.Value >= sticksRequired then -- I'm checking if sticks required is enough, on the server. local clone = ReplicatedStorage.Storage.Swords[toolName]:Clone() clone.Parent = plr.Backpack clone:Clone().Parent = plr.StarterGear else -- Do code if the condition is false end end) local GetPrice GetPrice = function(player, toolName) return ReplicatedStorage.Storage.Swords[toolName].Price.Value -- I put an IntValue named price inside the sword. end checkPrice.OnServerInvoke = GetPrice
local ReplicatedStorage = game:GetService("ReplicatedStorage") local price = ReplicatedStorage.GetPrice:InvokeServer("DiamondSword") local cloneTool = ReplicatedStorage:WaitForChild("CloneToolEvent") script.Parent.MouseButton1Click:Connect(function() cloneTool:FireServer("DiamondSword", price) end)